Struts 2 Execute action instead of welcome file

不羁的心 提交于 2019-12-24 11:12:22

问题


I'm working on a Struts 2 application and I want to execute an action (in fact I'm interested more on executing an interceptor) instead of simply showing a welcome file. What is the best way to achieve this?

Thanks in advance!


回答1:


Either redirect to the action from the welcome file, or use the action URL as a welcome file entry.

To do the latter, you'll likely need to set dispatcher elements on the element:

<filter-mapping>
    <dispatcher>REQUEST</dispatcher>
    etc.

Add FORWARD, INCLUDE, and ERROR as well, and the normal filter name/url.




回答2:


You have two well defined option both have been mentioned by Dave in his post.he has already described the Dispatcher option and other is to use redirection something like

<head>
    <META HTTP-EQUIV="Refresh" CONTENT="0;URL=example/MyAction.action">
</head>


来源:https://stackoverflow.com/questions/8071137/struts-2-execute-action-instead-of-welcome-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!