mirror of https://github.com/halo-dev/halo
Fix NullPointerException when getting ServletException
parent
773ebabad4
commit
562da7b04b
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.model.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
@ -18,6 +19,7 @@ import java.util.List;
|
||||||
* @date : 2018/1/12
|
* @date : 2018/1/12
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ToString
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_tag")
|
@Table(name = "halo_tag")
|
||||||
public class Tag implements Serializable {
|
public class Tag implements Serializable {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cc.ryanc.halo.model.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
@ -21,6 +22,7 @@ import java.util.Date;
|
||||||
* @date : 2017/11/14
|
* @date : 2017/11/14
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ToString
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "halo_user")
|
@Table(name = "halo_user")
|
||||||
public class User implements Serializable {
|
public class User implements Serializable {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ControllerExceptionHandler {
|
||||||
public JsonResult handleConstraintViolationException(ConstraintViolationException e) {
|
public JsonResult handleConstraintViolationException(ConstraintViolationException e) {
|
||||||
JsonResult jsonResult = handleBaseException(e);
|
JsonResult jsonResult = handleBaseException(e);
|
||||||
jsonResult.setCode(HttpStatus.BAD_REQUEST.value());
|
jsonResult.setCode(HttpStatus.BAD_REQUEST.value());
|
||||||
jsonResult.setMsg("Filed validation error");
|
jsonResult.setMsg("Field validation error");
|
||||||
jsonResult.setResult(e.getConstraintViolations());
|
jsonResult.setResult(e.getConstraintViolations());
|
||||||
return jsonResult;
|
return jsonResult;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class ControllerExceptionHandler {
|
||||||
public JsonResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
public JsonResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||||
JsonResult jsonResult = handleBaseException(e);
|
JsonResult jsonResult = handleBaseException(e);
|
||||||
jsonResult.setCode(HttpStatus.BAD_REQUEST.value());
|
jsonResult.setCode(HttpStatus.BAD_REQUEST.value());
|
||||||
jsonResult.setMsg("Filed validation error");
|
jsonResult.setMsg("Field validation error");
|
||||||
Map<String, String> errMap = ValidationUtils.mapWithFieldError(e.getBindingResult().getFieldErrors());
|
Map<String, String> errMap = ValidationUtils.mapWithFieldError(e.getBindingResult().getFieldErrors());
|
||||||
jsonResult.setResult(errMap);
|
jsonResult.setResult(errMap);
|
||||||
return jsonResult;
|
return jsonResult;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class CommonController implements ErrorController {
|
||||||
// Get the exception
|
// Get the exception
|
||||||
Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
|
Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
|
||||||
|
|
||||||
if (StringUtils.startsWithIgnoreCase(throwable.getMessage(), "Could not resolve view with name '")) {
|
if (throwable != null && StringUtils.startsWithIgnoreCase(throwable.getMessage(), "Could not resolve view with name '")) {
|
||||||
// TODO May cause unreasoned problem
|
// TODO May cause unreasoned problem
|
||||||
// if Ftl was not found then redirect to /404
|
// if Ftl was not found then redirect to /404
|
||||||
return "redirect:/404";
|
return "redirect:/404";
|
||||||
|
|
Loading…
Reference in New Issue