SSH中我想直接打开首页就可以把数据取出显示到首页,而不是要执行一个action之后才取出数据,然后跳转到页面.
我之前用的方法是:打开项目后直接跳转到一个页面,然后在这个页面请求Action 然后通过请求的这个action返回数据到首页。中间有了一个请求action的页面。我现在想的是打开项目时候就直接到首页,并把数据取出。这个怎么实现呢??
我之前用的方法是:打开项目后直接跳转到一个页面,然后在这个页面请求Action 然后通过请求的这个action返回数据到首页。中间有了一个请求action的页面。我现在想的是打开项目时候就直接到首页,并把数据取出。这个怎么实现呢??
解决方案 »
- js 可以如何写入session
- 判断是否是数字
- Jcreator
- 求高手帮忙分析下 数据库查询问题
- ReSultSet cannot be resolved to a type的问题在线等。。。。。
- Servlet action is not available ,实在整不出来了,无奈了……,只能指望大家了,叩谢叩谢!!!
- String[] 和Array的转换
- javabeen+JSP使用tomcat5 ,需要设置嘛?为什么我只要在jsp中用been就出问题!
- 怎样搭建WebService环境?马上给分!!!
- MyBatis #{} ${} 问题
- JS高手来!!!
- 关于jsp/servlet连接数据库的问题,大虾进来吧,绝对结贴给高分!!
<welcome-file>/index.action</welcome-file>
</welcome-file-list>
http://007ej.com/user.asp
在首页:
$(docunment).ready(function(){
//跳转到Action获取数据并返回数据
})
2、登陆成功跳到Action然后再跳到首页同时把数据传到首页,首页显示数据!
http://happyran.zbpifa.com
http://007ej.com/user.asp
这种方法不知道好不好:
用spring注入 就在JSP页面上 用
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
用ctx.getBean(); 里面就放 注入的对象
这样可以取到数据,但是这样不知道好不好!!
<jsp:forword xxxx.action>
还有就是通过ajax 返回html页面就可以了 试试吧
事实上都是两个jsp。
index.jsp只有
<jsp:forward page="index.action"></jsp:forward>
经过Action查询出数据,返回给main.jsp
大部分是这么做得
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框架,这样速度相对比就快
用spring注入 就在JSP页面上 用
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
用ctx.getBean(); 里面就放 注入的对象