zoukankan      html  css  js  c++  java
  • springmvc中重定向该如何处理?

    如果登录成功,会重定向到系统首页 response.sendRedirect("jsp/frame.jsp"); 在springmvc中,应该如何处理?是否可以直接使用 return "frame"; 来进行页面的重定向?

    一般情况下,控制器方法返回的字符串会被当成逻辑视图吗处理,这仅仅是惊醒服务端的页面跳转而已,并非客户端重新发送新的url请求,若想进行重定向操作,就需要加入 redirect: 前缀,springmvc将对它进行特殊处理,将 redirect: 当作指示符,其后的字符串作为url处理。如下

    @RequestMapping(value = "/dologin.html", method = RequestMethod.POST)
    public String doLogin(@RequestParam String userCode, @RequestParam String userPassword){
        //省略
        return "redirect:/user/main.html";
        //response.sendRedirect("jsp/frame.jsp");
    }
  • 相关阅读:
    08day 操作命令以及目录结构
    换工作
    json转为字典
    快速排序
    冒泡排序
    python函数-生成器
    关键字global
    函数的定义和参数调用
    count()函数与center()函数
    python字符串常用函数:strip()
  • 原文地址:https://www.cnblogs.com/yanguobin/p/11665146.html
Copyright © 2011-2022 走看看