当用户访问我的网站时,我想使操作默认运行。

这是用Java EEStruts2开发的经典Tomcat项目。我知道如何在web.xml中执行此操作:



<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>


但是,我想通过Struts2的动作来做到这一点。

最佳答案

尝试使用此代码,看看是否可行。

 <action name="index" class="myaction">
     <result>/index.jsp</result>
 </action>


您也可以尝试一下。

<welcome-file-list>
    <welcome-file>/myfolder/index.action</welcome-file>
</welcome-file-list>


另一种方法是在您的索引jsp中执行以下操作

<% response.sendRedirect("home.do"); %>


但是我不认为这是一个合适的方法

关于java - 用户访问系统时如何使操作默认运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14078233/

10-16 16:16