使用 Struts 2 实现 Spring Security [英] Implementing Spring Security with Struts 2

查看:53
本文介绍了使用 Struts 2 实现 Spring Security的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现 Spring Security + Struts2

I want to implement Spring Security + Struts2

我在执行项目时遇到问题:

I had a problem when I execute my project :

没有为命名空间[/]和与上下文路径[/Project]关联的动作名称[j_spring_security_check]映射的动作因为 struts.xml 中没有名为 'j_spring_security_check' 的动作

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

How can I resolve this? This is the code for Login.jsp

登录.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>

推荐答案

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

The form action should be handled by spring security before the struts filter. Make sure the order of filters is the following

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

这篇关于使用 Struts 2 实现 Spring Security的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆