日期:2014-05-17  浏览次数:20612 次

如何将tomcat默认首页直接访问action
本帖最后由 hyqinger 于 2012-12-29 20:24:01 编辑
因为首页有一些数据需要显示。所以希望默认首页能够先访问action

这是web.xml 的设置。
  <welcome-file-list>
    <welcome-file>index.action</welcome-file>
  </welcome-file-list>
这是struts.xml
    <action name="index" class="cn.action.Index" method="main">
    <result name="index">/index.jsp</result>
    </action>
直接访问http://localhost:8080/项目名称 
会报404错误。有没有能够不通过jsp重定向的方式直接先访问action呢。

------解决方案--------------------
如果你想打开的默认路径http://localhost:8080/ui/  那么你可以tomcat conf\Catalina\localhost路径下,新建一个xml文件,把下面的代码粘贴上,文件名ui.xml

<?xml version='1.0' encoding='utf-8'?>
<Context workDir="work\Catalina\localhost\ui" path="/ui" docBase="项目ui本地路径" useNaming="false" reloadable="true">
</Context>


ps:ui就是你默认想直接登录的页面。