struts中action的问题 比较麻烦

来源:百度知道 编辑:UC知道 时间:2024/09/20 03:19:47
我用的是ssh框架,用spring来控制struts
struts-config.xml中<action>中的type="org.springframework.web.struts.DelegatingActionProxy">

想在登录index.jsp的时候先到art.do中去执行一些查询操作,用的方法是在web.xml中把
<welcome-file-list>
<welcome-file>art.do?method=toIndex</welcome-file>
</welcome-file-list>
但是在art.do的toIndex中写了System.out.print做测试显示没执行到这个方法,编译很正常,没有报错现象,不知道用spring做控制的struts中的做法,望解答

welcome-file中不能直接使用这种struts连接的形式.
可以在这里配置成一个静态页面,然后在该页面上设置js的自动跳转就可以了.

web.xml:
<welcome-file-list>
<welcome-file>xxx.html</welcome-file>
</welcome-file-list>

xxx.html:
<script language="javascript">
window.location="art.do?method=toIndex";
</script>

楼主干吗把问题想那么复杂呢?

只需要在主页的上面加上

<script language="javascript">
window.location="art.do?method=toIndex";
</script>

这个就行了。。。

我想楼主应该知道什么时候执行上面的代码,什么时候不执行吧??(判断主页是不是有楼主想要的数据,没有的话再执行上面的代码)

这么不用我讲了吧。。呵呵。。

祝你好运。。。。

可以用过滤器啊!
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filte