名前空間、アクション、および Struts タグを使用してリンクを操作する方法を学ぼうとしています。
ページに簡単なログインフォームがありindex.jsp
ます:
<s:form action="login" method="POST" namespace="/welcome">
<s:textfield name="email" label="e-mail" type="email"></s:textfield>
<s:password name="password" label="Password" type="password"></s:password>
<s:submit value="Log-in"></s:submit>
</s:form>
<s:url var="url" namespace="/client" action="register"></s:url>
<p>
<s:a label="Register" href="#url" />
</p>
そして、次のマッピングstruts.xml
:
<struts>
<constant name="struts.devMode" value="true" />
<package name="welcome" namespace="/welcome" extends="struts-default">
<action name="index">
<result>/index.jsp</result>
</action>
</package>
<package name="client" namespace="/client" extends="struts-default">
<action name="register"
class="magazine.action.client.RegisterClientAction"
method="execute">
<result name="input" type="redirect">/index.jsp</result>
</action>
<action name="login"
class="magazine.action.client.LoginClientAction"
method="execute">
<result name="input" type="redirect">/WEB-INF/view/client/view.jsp
</result>
<result name="error" type="redirect">/index.jsp</result>
</action>
</package>
</struts>
が表示されindex.jsp
ていますが、デバッグ モードになっています: No configuration found for the specified action
。
また、登録リンクも表示されますが、壊れています。同様の投稿を見ましたが、回答の主な目標は、名前空間と構文の問題を確認することでした。私は Struts 2 のスターターですが、コードにその問題は見られませんでした。間違った方法で使用している可能性があります。