Error in Form Action attribute struts2

2019-02-19 12:49发布

My login.jsp is in the web folder.

And action for this is specified as :

struts.xml

<package name="admin" extends="struts-default" namespace="/secure">

<action class="actions.LoginAction" name="authenticateUser">
    <result name="success" type="redirect">index</result>
    <result name="input">/login.jsp</result>
    <result name="error">/login.jsp</result>
</action>
</package>

login.jsp

<s:form action="secure/authenticateUser" method="post">

</s:form>

========================

At first request it works.

but if validate() method of action returns errors then it creates url as:

"secure/secure/authenticateUser" for the Form action attribute.

I also tried <s:url> tag but still same problem can anybody help me. or may provide alternate solution for this.

1条回答
倾城 Initia
2楼-- · 2019-02-19 13:15

Your action attribute on the form tag possibly has a wrong name. Use

<s:form namespace="/secure" action="authenticateUser" method="post"> 
查看更多
登录 后发表回答