当我尝试使用Spring Security的自定义登录表单时,无论是否输入正确的凭据,它都会将我返回到/ admin/login页面.当我使用空<form-login />的安全检查工作正常.但是,当我添加一个自定义时,<form-login login-page="/admin/login" />我会一直回到同一页面.我试图添加一个,default-target-url="admin/forSale" />但我仍然返回登录页面.在提供正确的凭据并返回到登录页面后,我尝试访问受保护的URL并再次返回登录页面,因此我99%确定根本没有执行安全检查.
将action="<c:url value='j_spring_security_check' />"在我的jsp创建一个URL http://localhost:8080/sharleepark/admin/j_spring_security_check.我假设过滤器应该仍然选择它并相应地处理安全性?
我确信我的控制器或JSP中有一个简单的错误,我没有接受.我也在使用Tiles2模板,这可能是问题的一部分吗?我已经花了几天时间在这上面尝试了所有可以找到的春季安全教程但无济于事,非常感谢您的帮助.
为spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd ">
<!-- Scans packages to auto declare the beans we require -->
<context:component-scan base-package="au.com.sharleepark.controller" />
<context:component-scan base-package="au.com.sharleepark.service" />
<context:component-scan base-package="au.com.sharleepark.hibernate" />
<context:component-scan base-package="au.com.sharleepark.helper" />
<mvc:annotation-driven />
<tx:annotation-driven />
<!-- Map our static resources to a friendly URL -->
<mvc:resources location="/static/" …Run Code Online (Sandbox Code Playgroud)