日期:2014-05-20  浏览次数:20750 次

SSH如何访问首页就直接获取到数据
SSH中我想直接打开首页就可以把数据取出显示到首页,而不是要执行一个action之后才取出数据,然后跳转到页面.
我之前用的方法是:打开项目后直接跳转到一个页面,然后在这个页面请求Action 然后通过请求的这个action返回数据到首页。中间有了一个请求action的页面。我现在想的是打开项目时候就直接到首页,并把数据取出。这个怎么实现呢??

------解决方案--------------------
<welcome-file-list>
<welcome-file>/index.action</welcome-file>
</welcome-file-list>
------解决方案--------------------
1、异步--jQuery
在首页:
$(docunment).ready(function(){
//跳转到Action获取数据并返回数据
})
2、登陆成功跳到Action然后再跳到首页同时把数据传到首页,首页显示数据!
http://happyran.zbpifa.com
http://007ej.com/user.asp
------解决方案--------------------
你可以jsp include 到你的action ,返回你include的jsp路径
还有就是通过ajax 返回html页面就可以了 试试吧
------解决方案--------------------
写个AdminFilter类实现Filter
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
//业务处理,跳转到的action类
newresponse.sendRedirect("*.action");
}

<filter>
<filter-name>AdminFilter</filter-name>
<filter-class>包.AdminFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>AdminFilter</filter-name>
<url-pattern>/index.jsp</url-pattern> <!--将首页拦截到 -->
</filter-mapping>

//如果要初始化数据,建议用ajax,或dwr框架,这样速度相对比就快