1

Javascriptを使用してエラーメッセージを表示し、メッセージはSpring [サーブレット]から来ます。

次のようになります。

@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);
}

400 エラーを出す代わりに json メッセージを送信する方法はありますか?

4

0 に答える 0