当前位置: 代码迷 >> Java Web开发 >> 关于struts跳转的有关问题
  详细解决方案

关于struts跳转的有关问题

热度:5568   发布时间:2013-02-25 21:20:52.0
关于struts跳转的问题
web.xml中
<welcome-file-list>  
  <welcome-file>index.jsp</welcome-file>  
</welcome-file-list> 
jsp中
<% response.sendRedirect("bookindex!visitors.action"); %>
可以跳转到想要的界面visitors.jsp
为什么改成
web.xml中
<welcome-file-list>  
  <welcome-file>bookindex!visitors.action</welcome-file>  
</welcome-file-list>
找不到页面呢?

 

------解决方案--------------------------------------------------------
<welcome-file></welcome-file> 节点中只能包含HTML、HTM、TEXT..。实体物理文件路径,不能访问控制器,你可以配置成<welcome-file>index.jsp </welcome-file>,然后在index.jsp 里做转发:
1.<body onload="javascript:window.location='bookindex!visitors.action';">
2.或者<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <jsp:forward page="bookindex!visitors.action"></jsp:forward>
3.方法很多的可以在百度搜一搜
------解决方案--------------------------------------------------------
你可以选择使用ajax 来实现异步的调用action并把数据写进去。而不用去跳转。
  相关解决方案