更新时间:2021-08-14 20:47:52
首先,如果您不希望用户认为他们的名字有扩展名,您应该摆脱行动扩展。
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中,您不需要使用表单
标签,但锚标签。并使用已知名称。
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>