vue-resource post请求 参数写法

前端代码: 

Vue.login = function ($http, sysUserName, password, successFn, errorFn) {
    $http.post('user/login' , {sysUserName,password},{emulateJSON: true}).then(
            successFn, errorFn
    );        
};

 后端代码:

@PostMapping("/login")
    public APIResult login(@RequestParam(value = "sysUserName") String sysUserName, @RequestParam(value = "password") String password, HttpSession httpSession){
        SysUser user = userService.findSysUser(sysUserName,password);
        if (user != null){
            SysUserVO sysUserVO = this.convertToSysUserVO(user);
            httpSession.setAttribute("SysUser",sysUserVO);
            return new APIResult(SUCCESS_CODE,USER_LOGIN_SUCCESS,sysUserVO);
        }
        return getAPIResultUtil.getResultWithWrong(new APIResult(),USER_LOGIN_FAILURE);
    }

 

你可能感兴趣的:(vue-resource post请求 参数写法)