页面跳转小问题,帮者均有分,谢谢!

lbxuwei 2006-10-28 10:27:06
我在做一个用Tomact+struct开发的小项目时.出现一个让人十分郁闷的问题,我的
<welcome-file-list>
<welcome-file>newsmain.do</welcome-file>
</welcome-file-list>
怎么也不去执行newsmain.do动作.当我这样写时:<form action="newsmain.do" method="post">却可以执行newsmain.do动作.真搞不懂啊.我的配置文件如下:

web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>actionServlet</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>actionServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>newsmain.do</welcome-file>
</welcome-file-list>
</web-app>

struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
</form-beans>
<global-forwards>
<forward name="toNewsMain" path="/index.jsp" />
</global-forwards>
<action-mappings>
<action path="/newsmain" type="news.MnewsAction" input="/error.jsp" /> </action-mappings>
</struts-config>
...全文
86 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lbxuwei 2006-10-28
  • 打赏
  • 举报
回复
非常感谢!
jlusdy 2006-10-28
  • 打赏
  • 举报
回复
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
index.html里面写:
<body bgcolor="#FFFFFF" text="#000000">
<script language="javascript">
location.href = "<%=request.getContextPath()%>/newsmain.do"
</script>
</body>
lbxuwei 2006-10-28
  • 打赏
  • 举报
回复
先谢谢你!
那请问应该怎么写这个页面载入呢?因为是主页,所以不好弄啊.还望各位帮帮我啊!
jlusdy 2006-10-28
  • 打赏
  • 举报
回复
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
然后再在index.html里写个页面载入就跳转到newsmain.do的动作

我也一直用这种

welcome-file-list 里面直接写action真没试过
wizardblue 2006-10-28
  • 打赏
  • 举报
回复
我见过的做法是:

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
然后再在index.html里写个页面载入就跳转到newsmain.do的动作
zhengjigang 2006-10-28
  • 打赏
  • 举报
回复
不能那写,你要在一个页面中通过Forward中接上你想要到的网才可以啊。
在服务器启动,它加载web.xml和struts.xml。后者才是Struts框架的事啊,web.xml是web容器
管理的啊,比如说:tomcat

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧