web-xml设置问题

tjdghk 2009-07-01 02:10:37
当前web-xml的设置如下,

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


现在我需要把<welcome-file>index.html</welcome-file>这部分
直接设置为 .do 的形式, 即请求方式。

该怎么改呢?




...全文
105 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ami121 2009-07-02
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 tjdghk 的回复:]
问题解决了,感谢各位给出的方法~
大家给的方法都没错,但是不是我想要得,我就是想在welcomefile里直接写.do的方式。
现将我调试成功的方法贴出来,给大家参考。
这是web.xml的设定,struts.config的设定没变
<welcome-file>dispTop.do </welcome-file>
之后,我在项目根目录建立了一个名字为dispTop.do的空文件。
这样我的默认欢迎访问页面就是dispTop的action执行后的页面了。
还是感谢各位,结贴去了,分…
[/Quote]

不错 有想法啊
tjdghk 2009-07-02
  • 打赏
  • 举报
回复
问题解决了,感谢各位给出的方法~
大家给的方法都没错,但是不是我想要得,我就是想在welcomefile里直接写.do的方式。
现将我调试成功的方法贴出来,给大家参考。
这是web.xml的设定,struts.config的设定没变
<welcome-file>dispTop.do</welcome-file>
之后,我在项目根目录建立了一个名字为dispTop.do的空文件。
这样我的默认欢迎访问页面就是dispTop的action执行后的页面了。
还是感谢各位,结贴去了,分就给前面几位了,谢谢。

yuanjianbin 2009-07-01
  • 打赏
  • 举报
回复
很简单
web.xml文件配置不变
<welcome-file-list>
<welcome-file>index.html </welcome-file>
</welcome-file-list>


index.html


<HTML>
<HEAD>
<TITLE>welcome</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</HEAD>
<body>
<script language="javaScript">
window.location = "***.do";
</script>
</body>
</HTML>
ky000 2009-07-01
  • 打赏
  • 举报
回复
只有像1lou这样,到请求后再转向
[Quote=引用 1 楼 Ami121 的回复:]
在struts-conf.xml
配置一个全局转发
XML code<global-forwards>

<forward name="findhistory" path="/findhistory.do"/>
</global-forwards>


web.xml
配置
XML code<welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list>

index.jsp 页面
Java code<logic:forward name="findhistory"/>

[/Quote]
tjdghk 2009-07-01
  • 打赏
  • 举报
回复
那么有什么其他方法可以不通过index.html???
Ami121 2009-07-01
  • 打赏
  • 举报
回复
<welcome-file-list>
<welcome-file>dispTop.do </welcome-file>
</welcome-file-list>
这种写法是不行的
tjdghk 2009-07-01
  • 打赏
  • 举报
回复
index.html 里指定有以下code
<meta http-equiv="Refresh" content="0;url=/c1s/dispTop.do" />
所以
<welcome-file-list>
<welcome-file>index.html </welcome-file>
</welcome-file-list>
这么写的话正常执行,

但是我现在要想不通过index.html, 直接在welcome-file上指定如下,例:
<welcome-file-list>
<welcome-file>dispTop.do</welcome-file>
</welcome-file-list>


有没有不通过index页面的方法?
huangan0301 2009-07-01
  • 打赏
  • 举报
回复
直接这样是不行的
zm_hs 2009-07-01
  • 打赏
  • 举报
回复
到index里重定向一下吧
ouyangxiaokang6 2009-07-01
  • 打赏
  • 举报
回复
不可以直接在那里面转向,必须到请求的画面后再转向,像1楼那样
YSocket 2009-07-01
  • 打赏
  • 举报
回复
好像不可以

你在index的首页里面重定向到xxx.do
既可以了
xuexijava 2009-07-01
  • 打赏
  • 举报
回复
up
Ami121 2009-07-01
  • 打赏
  • 举报
回复
在struts-conf.xml
配置一个全局转发
  <global-forwards>  [code=Java]

<forward name="findhistory" path="/findhistory.do"/>
</global-forwards>[/code]

web.xml
配置
 <welcome-file-list> 
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


index.jsp 页面

<logic:forward name="findhistory"/>

81,094

社区成员

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

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