更新时间:2022-04-13 22:41:08
首先你应该去掉动作扩展,如果你不想让用户认为他们的名字有扩展名.
First of all you should get rid of action extension, if you don't want user to think their name has an extension.
<constant name="struts.action.extension" value=",,action"/>
接下来的模式匹配器应该是regex
.
Next the pattern matcher should be regex
.
<constant name="struts.patternMatcher" value="regex"/>
动作映射
<action name="/CustomURL/{username}" class="com.rajesh.struts2.CustomURL" method="customUrl">
<result name="success">welcome.jsp</result>
</action>
在JSP 中你不需要使用form
标签,而是使用anchor 标签.并使用已知名称.
In the JSP you don't need to use form
tag, but anchor tag. And use known names.
<a href="http://localhost:8080/CustomURL/rajesh">Click my name</a>