java - 请教一个Spring里面@ResponseBody问题
PHP中文网
PHP中文网 2017-04-17 11:51:58
0
2
198
@RequestMapping(value="/login", method=RequestMethod.POST)
@ResponseBody
public String auth(String email, String password, String _ref, HttpSession session) {

    if(_ref.equals("loginPage")) {
        //这个里面不使用@ResponseBody
        if (userDao.get(email) != null) {
            session.setAttribute("email", email);
            return "redirect:/";
        }
        return "login";
    } else {
        //这个里面使用@ResponseBody
        //这个返回 json
        String msg = "{\"err\":403,\"msg\":\"用户名或密码错误\"}";
        return msg;
    }

}

上面代码,在IF判断里面怎么使用@ResponseBody,而不是定义在整个方法里面

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
小葫芦

It is originally defined in the method

洪涛

This cannot exist in the same controller method at the same time. Write it in two separate methods

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!