1

I want to implement Spring Security + Struts2

I had a problem when I execute my project :

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

How can I resolve this? This is the code for 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>
Roman C
  • 49,761
  • 33
  • 66
  • 176
hafid8h
  • 13
  • 4

1 Answers1

0

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>
Roman C
  • 49,761
  • 33
  • 66
  • 176