当前位置: 代码迷 >> Java Web开发 >> 关于在struts2中怎么将.action加入到web.xml中的<welcome-file-list>上 急
  详细解决方案

关于在struts2中怎么将.action加入到web.xml中的<welcome-file-list>上 急

热度:10198   发布时间:2013-02-25 21:13:57.0
关于在struts2中如何将.action加入到web.xml中的<welcome-file-list>下 急!在线等!!!!
小弟初学struts2不知道这个.action应该如何加到web.xml中的<welcome-file-list>下,需要如何配置;小弟倒是用 <servlet>
<servlet-name>show</servlet-name>
<servlet-class>com.Web.Action.Selection</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>show</servlet-name>
<url-pattern>/Show.action</url-pattern>
</servlet-mapping>
然后 <welcome-file-list>
  <welcome-file>Show.action</welcome-file>
  </welcome-file-list>
实现
可是这样要求class引用servlet,感觉不是struts2的框架,想问问各位高手在struts2中如何实现。谢谢
(注:.action主要用于从数据库中调出数据显示)

------解决方案--------------------------------------------------------
lz是不是想首页访问show.action啊。可以访问首页上做个提交,不过直接web.xml里面配置action到时没见过。我们这是这样做的
web.xml
<welcome-file-list>
<welcome-file>jump.jsp</welcome-file>
</welcome-file-list>

jump.jsp里通过这段代码访问action':
<meta http-equiv='refresh' content='0;url=show.action'>
------解决方案--------------------------------------------------------
探讨
lz是不是想首页访问show.action啊。可以访问首页上做个提交,不过直接web.xml里面配置action到时没见过。我们这是这样做的
web.xml
<welcome-file-list>
<welcome-file>jump.jsp </welcome-file>
</welcome-file-list>

jump.jsp里通过这段代码访问action':
<meta http-equiv='refresh' content='0;url=show.action'>

------解决方案--------------------------------------------------------
<welcome-file-list>
<welcome-file>index.jsp </welcome-file>
</welcome-file-list>

index.jsp里
<jsp:forword page="show.action">
------解决方案--------------------------------------------------------
3,4,5楼说的都正确
欢迎页面随便搞个JSP 
里面在转发到你要的Action
------解决方案--------------------------------------------------------
welcome-file-list里面不能放映射信息,只能是实际存在的文件,比如index.jsp,index,index.htm

可以在这个页面上自动跳转到其他页面

页面自动跳转:

把如下代码加入<head>区域中

<meta http-equiv="refresh" content="1;url=<%=request.getContextPath()%>/index.do">

注:content="1 是时间控制,表示1秒后自动跳转到要跳转的页面.
content="0 表示打开该页后立即跳转到你要跳转的页面.
url 是要跳转的路径
------解决方案--------------------------------------------------------
可以在根目录下建一个空白的Show.action,这样tomcat就不会报404错误而Show.action也可以正确的执行了
  相关解决方案