我在用SSH(Struts+spring+hibernate)的框架写一个登陆的模块。以前我是用servlet的写的时候有HttpSession,保存用户实现类是于用户看某些页面的时候要验证权限,但现在用action写,少了个HttpServletRequest,不知道怎么实现这个功能呢?
之前写法 Httpsession session =request.getSession();
session。setAttribute("User",name);但现在我应该怎么使用这个功能来控制权限呢
之前写法 Httpsession session =request.getSession();
session。setAttribute("User",name);但现在我应该怎么使用这个功能来控制权限呢
解决方案 »
- java http 分段下载
- fusion charts free 问题
- 请问是一个jsp网页对应一个servlet,还是整个web系统对应一个servet?
- 如何控制fckeditor工具栏里面东西的多少?
- 有没有办法在页面上遍历显示出session容器中,所有对象!!!
- 我用jsp写做的网站在局域网中运行.
- 高难度数据库系统设计——太苛刻了,不知道如何下手!
- 关于用jsp通过javabean访问oracle数据库中的中文数据,出现中文乱码,求救!
- 创建类问题?
- 急急急!!!!前贴没人搭理啊 重开一贴求解答啊关于httpclient的
- Hibernate 出现attempted to assign id from null one-to-one property
- 新手求问关于数据类型转换的问题
方法挺多的
ActionContext.getContext().getSession().put("abc",abc);
FilterChain chain)
throws IOException, ServletException {
response.setContentType("text/html;charset=utf-8");
HttpSession session = ((HttpServletRequest)request).getSession();
User user = (User)session.getAttribute("user");
if(user==null||user.equals("")){
HttpServletResponse res = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;
res.sendRedirect(req.getContextPath()+"/login.jsp");
}else{
chain.doFilter(request, response);
}