spring security 默认登录 404

qq_25280003 2016-11-08 12:54:45
http://127.0.0.1:8080/spring/spring-security-login 找不到登录页面
security xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.1.xsd">

<!-- 配置不过滤的资源(静态资源及登录相关) -->
<sec:http pattern="/**/*.css" security="none"></sec:http>
<sec:http pattern="/**/*.jpg" security="none"></sec:http>
<sec:http pattern="/**/*.jpeg" security="none"></sec:http>
<sec:http pattern="/**/*.gif" security="none"></sec:http>
<sec:http pattern="/**/*.png" security="none"></sec:http>
<sec:http pattern="/js/*.js" security="none"></sec:http>

<sec:http pattern="/login.jsp" security="none"></sec:http>
<sec:http pattern="/getCode" security="none" /><!-- 不过滤验证码 -->
<sec:http pattern="/test/**" security="none"></sec:http><!-- 不过滤测试内容 -->

<sec:http auto-config="true">


<sec:intercept-url pattern="/app.jsp" access="ROLE_SERVICE"/>

</sec:http>

<sec:authentication-manager>
<sec:authentication-provider>
<sec:user-service >
<sec:user name="admin" password="admin" authorities="ROLE_ADMIN"/>
</sec:user-service>
</sec:authentication-provider>
</sec:authentication-manager>

</beans>
web xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<!-- 使用Java配置 -->


<!-- 指定所使用的Java配置类 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml
classpath:applicationContext-security.xml</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 使用Java配置 -->

<!-- 指定DispatcherServlet的配置类 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:appServlet-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>


</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>





</web-app>

...全文
1068 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_25280003 2016-11-08
  • 打赏
  • 举报
回复
引用 1 楼 u013559751 的回复:
<sec:form-login login-page="/sign-in" login-processing-url="/auth-check" username-parameter="username" password-parameter="password" authentication-success-handler-ref="authenticationSuccessHandler" authentication-failure-handler-ref="authenticationFailureHandler" /> 不用配置这个?
不配form-login 好像用的默认的登录页面
达人游戏男孩 2016-11-08
  • 打赏
  • 举报
回复
<sec:form-login login-page="/sign-in" login-processing-url="/auth-check" username-parameter="username" password-parameter="password" authentication-success-handler-ref="authenticationSuccessHandler" authentication-failure-handler-ref="authenticationFailureHandler" /> 不用配置这个?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧