1

我使用 Javascript 显示错误消息,消息来自 Spring[Servlet]。

它看起来像这样:

@RequestMapping(value="/updatePolicyInformation/accessManage/", method=RequestMethod.POST)
public @ResponseBody Map updatePolicyInformationAccessManage(
        @RequestParam(required=true) Integer m_idx,
        @RequestParam(required=true) Integer mode,
        @RequestParam(required=true) Integer use_auto_login,
        @RequestParam(required=true) Integer use_auto_halt,
        @RequestParam(required=true) Integer use_browser_acesss){

    /* This above @RequestParam generates 400 error if parameter is not the type of Integer. but I'd like to give JSON object instread of 400 error */
    /* {  (example)
          status : error,
          message : invalid parameter type
       }
    */

    if(deviceService.updatePolicyInformation("monitor.device.policy.update", paramMap) == 1)
        return JSON.result(JSON.SUCCESS, "SUCCESS!!!"); // << this part return json status code.
    else 
        return JSON.result(JSON.ERROR);
}

有没有办法发送 json 消息而不是给出 400 错误?

4

0 回答 0