gpt4 book ai didi

java - 使用 Struts 2 实现 Spring Security

转载 作者:太空宇宙 更新时间:2023-11-04 13:31:43 25 4
gpt4 key购买 nike

我想实现 Spring Security + Struts2

执行项目时遇到问题:

There is no Action mapped for namespace [/] and action name [j_spring_security_check] associated with context path [/Project] because there is no action named 'j_spring_security_check' in 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>

最佳答案

表单操作应该由 spring security 在 struts 过滤器之前处理。确保过滤器的顺序如下

<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>

关于java - 使用 Struts 2 实现 Spring Security,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32128662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com