当用户需要执行某个操作,该操作需要用户登录之后才能操作,该用户尚未登录,跳转到登录 登录后跳转到原页面。
求示例。

解决方案 »

  1.   

    使用refer,在跳转到登陆之前,传递当前界面地址,登陆之后,再直接跳转到刚才传递的地址参数即可。
      

  2.   

    http://www.360doc.com/content/10/0422/11/15643_24320208.shtml
      

  3.   

    <result name="success">/其他页面</result>////成功跳转
    <result name="error">/login</result>/////原来的页面在你的action里面返回值 如果返回 SUCCESS 就跳转到了其他页面
    如果返回了 ERROR 就返回了登录页面
      

  4.   

    自已写一个拦截器类loginInterceptor  implements HandlerInterceptor,实现preHandle方法,方法中如果验让不过直接 res.sendRedirect("jsp/loigin.jsp");
            return false; 然后在配制文件中设置一下。<bean id="loginInterceptor" class="com.yy.LoginInterceptor"></bean><bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> 
    <list>
     <ref bean="loginInterceptor" />
    </list>
    </property> 
    <property name="mappings">
    <props>
    <prop key="aa.action">XXaction</prop>
                                    //添加要验让的其他请求
    </props>
    </property>
    </bean> 
      

  5.   

    1.可以写一个拦截器来来处理就,判断session中是否有该用户,若没有用户直接return Action.LOGIN(在这里举个例子回到登录页面了)。建议使用第一种方案。
    2.也可以在每个每个Action后台代码判断session中是否有该用户,若没有直接return “login”;
    public String save() throws Exception {

    Map session = ActionContext.getContext().getSession();
    User user = (User) session.get("user");

    if (user != null&&file!=null) {
    for (int i = 0; i <file.length; i++) {
    InputStream is = new FileInputStream(file[i]);
    String root = ServletActionContext.getRequest().getRealPath(
    "/photo");
    File destFile = new File(root, this.fileFileName[i]);
    OutputStream os = new FileOutputStream(destFile);
    byte[] buffer = new byte[400];
    int length = 0;
    while ((length = is.read(buffer)) > 0) {
    os.write(buffer, 0, length);
    }
    is.close();
    os.close();
    String path = "/BBS/photo/" + this.fileFileName[i];
    session.put("path", path);
    Photo photo = new Photo();
    photo.setDate(new Date().getTime());
    photo.setPhoto_name(this.photo.getPhoto_name().get(i));
    photo.setPhoto_introduce(this.photo.getPhoto_introduce().get(i));
    photo.setPhoto_path(path);
    photo.setUser(user);
    HttpServletRequest request = ServletActionContext.getRequest();
    request.setAttribute("photo", photo);
    photoService.save(photo);
    }
    return SUCCESS;
    } else
    return INPUT;
    }
      

  6.   


    我的意思是:
     比如:我现在在csdn的下载页面,点击下载时它提示我没有登录,登录后就直接跳转到刚刚下载的页面   而没有跳转社区中心  
      我要实现的是这种功能   ?????
     
      
      

  7.   

    可以做一个通用的jsp页面,里面做判断,只要未登录就跳转到登录界面!
    然后所有的页面都包含这个jsp就可以了~~
      

  8.   

    你们说的这种我会:
       假如:一个用户登录后 就跳转到index.jsp
            我现在在下载页面down.jsp  当我点击下载的时候提示我登录(所有的登录肯定都会跳转到index.jsp) 但是我现在想跳到down.jsp
      这种功能怎么实现
      

  9.   

    自己写个拦截器 拦截session中的用户就可以了,没有就跳到登录 有就是继续下一个action