Commit 0dbb4e47 authored by 董建华's avatar 董建华

增加异常抓取

parent 71f8b722
...@@ -11,6 +11,7 @@ import org.springframework.validation.BindException; ...@@ -11,6 +11,7 @@ import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError; import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -152,7 +153,7 @@ public class ExceptionHandlingController implements IBaseController { ...@@ -152,7 +153,7 @@ public class ExceptionHandlingController implements IBaseController {
return null; return null;
} }
@ExceptionHandler({DataException.class,IllegalArgumentException.class}) @ExceptionHandler({DataException.class})
@ResponseBody @ResponseBody
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public JsonResult handleDataException(DataException e) { public JsonResult handleDataException(DataException e) {
...@@ -179,4 +180,11 @@ public class ExceptionHandlingController implements IBaseController { ...@@ -179,4 +180,11 @@ public class ExceptionHandlingController implements IBaseController {
public JsonResult resubmissionException(ResubmissionException re) { public JsonResult resubmissionException(ResubmissionException re) {
return JsonResult.buildErrorStateResult(re.getMessage(), null); return JsonResult.buildErrorStateResult(re.getMessage(), null);
} }
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public JsonResult handelMissingServletRequestParameterException(MissingServletRequestParameterException re) {
return JsonResult.buildErrorStateResult(re.getMessage(), null);
}
} }
...@@ -13,10 +13,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -13,10 +13,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -67,8 +64,9 @@ public class AppletController { ...@@ -67,8 +64,9 @@ public class AppletController {
/** /**
* @return * @return
*/ */
@Validated
@PostMapping("/login") @PostMapping("/login")
public JsonResult login(String appName, String openId, String utmSource) { public JsonResult login(@RequestParam String appName, @RequestParam String openId, String utmSource) {
if (!appNames.contains(appName)) { if (!appNames.contains(appName)) {
throw new DataException("appName不合法"); throw new DataException("appName不合法");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment