controller之间进行跳转(带参数)

Controller层

/**
     * 跳转到入库回收页面
     *
     * @return
     */
    @RequestMapping("/scan")
    public String scanLogin(Model model,@ModelAttribute(value="msg")String msg) {
        HttpContextTool.getSession().invalidate(); //进来之前清空所有session
        //查询该数据库是否有该洗涤厂信息 如果有就向前台传一个参数
        if(washingService.selectCount(new EntityWrapper())<1){
            model.addAttribute("washIsTrue",1);
        }
        if(ToolUtil.isNotEmpty(msg)){
            model.addAttribute("msg",msg);
        }
        return "scan/login_ruku";
    }

    /**
     * 用户登录验证
     * @param empLogin
     * @param empPassword
     * @return
     */
    @PostMapping("/scanLogin")
    public String scanLogin(String empLogin, String empPassword, RedirectAttributes redirectAttributes) {
        if(washingService.selectCount(new EntityWrapper())<1){     //判断系统是否选择洗涤厂
            redirectAttributes.addFlashAttribute("msg", "请先进行初始化");
            return "redirect:/scan";
        }
        if(ToolUtil.isEmpty(empLogin)||ToolUtil.isEmpty(empPassword)){   //判断账户密码是否为空
            return "redirect:/scan";
        }
        Emp emp=empService.selectOne(new EntityWrapper().eq("login_name",empLogin).eq("login_pass",empPassword));
        if (ToolUtil.isEmpty(emp)) {
            redirectAttributes.addFlashAttribute("msg", "用户不存在或密码错误");
            return "redirect:/scan";
        }
        if (ToolUtil.isNotEmpty(emp)) {
            HttpContextTool.getSession().setAttribute("emp", emp);
            return "scan/scan";
        }
        redirectAttributes.addFlashAttribute("msg", "登录异常");
        return "redirect:/scan";
    }

js接受参数

 var msg = [[${msg}]];

你可能感兴趣的:(js)