struts+stpring+struts 首页数据加载问题

来源:百度知道 编辑:UC知道 时间:2024/06/12 06:54:23
我要做个咨询的系统
首页有很多数据得在第一次访问时加载进来
用的是SSH框架
我不知道是该用标签在页面调用
还是进入首页时先forword到action再回来
可到了action回来的路径变成.do结尾
这是我不想看到的
请问有什么好的方法可以加载数据不用显示回来时action的路径

不知道楼主所说的想想隐藏.do呢,还是想直接连action的名称都不显示呢!
不过不管怎么解决,只和struts有关,和hibernate、spring无关。
解决的方法会有多种:
(1)a.do 是你在struts-config.xml中path配置的,通过.do 就可以调程序中你写的method 然后 struts转发到
xml配置文件所对应的jsp文件
列如:
<action-mappings>

<action path="/a" type="com.ums.action.UserAction" parameter="findUsers">
<forward name="list" path="/a.jsp"/>
</action>
path不用写成:path="/a.do"因为容器会默认为a.do写上反而会错
在浏览器中的url中如果写a.do它就 会执行type指定的UserAction类
调用它的findUsers方法,如果这个方法的:
public ActionForward findUsers(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
Collection users = biz.findUsers();
request.setAttribute("users", users);
return mapping.findForward("list");
}
因为返回return mapping.findForward("list");list对应 配置的struts-config.xml <forward name=&q