Poo*_*ool 3 java xml struts struts2
我是Struts 2的新手,我遇到过这种语法(在教程中推荐).
<action name="Register_*" method="{1}" class="Register">
<result name="input">/member/Register.jsp</result>
<result type="redirectAction">Menu</result>
</action>
Run Code Online (Sandbox Code Playgroud)
我知道它调用了Register.{1}方法.问题是用户可能会输入另一个(随机)值并导致500错误(这将错误地记录为错误).
如何防止这种情况?
在我的应用程序中,我们使用它如下:
<action name="*/*" class="{1}Action" method="{2}">
<interceptor-ref name="CustomAuthStack" />
<result>/pages/{1}/{2}.jsp</result>
<result name="input">/pages/error/denied.jsp</result>
<result name="logout">/pages/error/denied.jsp</result>
<!-- methods that come back to listing after processing -->
<result name="remove" type="redirectAction">{1}/list</result>
<result name="save" type="redirectAction">{1}/list</result>
<result name="enable" type="redirectAction">{1}/list</result>
....
</action>
Run Code Online (Sandbox Code Playgroud)
对于像myapp/users/list这样的斜杠,你必须使用斜杠启用斜杠
<constant name="struts.enable.SlashesInActionNames" value="true" />
Run Code Online (Sandbox Code Playgroud)
在strus.xml中.
所以现在你有一个标准:
action - > UserAction jsp -----> users/list.jsp
等等
| 归档时间: |
|
| 查看次数: |
16964 次 |
| 最近记录: |