我正在尝试使用spring-security
在所有配置之前
http://localhost:9090/app/login2.xhtmlrequest,工作与我预期的一样。
我添加了一个控制器:
@Controller
@RequestMapping("/auth")
public class LoginController {
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String getLoginPage(@RequestParam(value="error", required=false) boolean error,
ModelMap model) {
return "login2.xhtnml";
}
}我在web.xml中有:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/spring-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>使用此配置在我调用
http://localhost:9090/app/login2.xhtml错误来了
WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/app/login2.xhtml] in DispatcherServlet with name 'spring'但是当我将配置映射更改为
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>http://localhost:9090/app/login2.xhtml的工作方式和我预期的一样
但
http://localhost:9090/app/auth/login没有错误,没有异常,没有重定向,我认为dispatcher servlet不能知道这个请求。
http://localhost:9090/app/app/auth/login与配合使用
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>我的理解是:
dispatcher servlet使用"http://localhost:9090/"作为搜索login2.xhtml的基础,并使用"http://localhost:9090/app"搜索/auth/login URL。
我不知道在哪里设置它,为什么它们是不同的。
发布于 2013-07-26 01:17:52
您是否已将SpringSecurityFilterChain添加到web.xml?
<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>如果容器启动(从日志文件),你能跳过注册的“请求绑定”吗?
https://stackoverflow.com/questions/12070866
复制相似问题