我想实现Spring Security + Struts2
执行项目时出现问题:
没有映射名称空间[/]的动作和与上下文路径[/ Project]相关联的动作名称[j_spring_security_check] 因为没有名为' j_spring_security_check'在struts.xml中
我该如何解决这个问题?这是Login.jsp
的Login.jsp
<form action="/j_spring_security_check" method="POST">
<input type="text" placeholder="ID Utilisateur" name="j_username" autofocus>
<input type="password" placeholder="Mot de passe" name="j_password">
<button type="submit"><i class="fa fa-lock"></i> Se Connecter</button>
</form>
答案 0 :(得分:0)
表单操作应该在struts过滤器之前由spring security处理。确保过滤器的顺序如下
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>