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

增加异常抓取

parent 71f8b722
......@@ -11,6 +11,7 @@ import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -152,7 +153,7 @@ public class ExceptionHandlingController implements IBaseController {
return null;
}
@ExceptionHandler({DataException.class,IllegalArgumentException.class})
@ExceptionHandler({DataException.class})
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public JsonResult handleDataException(DataException e) {
......@@ -179,4 +180,11 @@ public class ExceptionHandlingController implements IBaseController {
public JsonResult resubmissionException(ResubmissionException re) {
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
......@@ -67,8 +64,9 @@ public class AppletController {
/**
* @return
*/
@Validated
@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)) {
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