GitHub
src="//ghbtns.com/github-btn.html?user=je-ge&repo=spring-boot&type=watch&count=true" scrolling="0" width="110" height="20">
edatagrid扩展组件
- edatagrid组件是datagrid的扩展组件,增加了统一处理CRUD的功能,可以用在数据比较简单的页面。
- 使用的时候需要额外引入jquery.edatagrid.js
- 为了能够把后台自动捕获的异常显示到前台这里必须使用最新版本的jquery.edatagrid.js文件
可以直接在数据表格里面进行CRUD
项目图片

AjaxResult.java,改变输出属性适应edatagrid.onError方法
package com.jege.spring.boot.json;
/**
* @author JE哥
* @email 1272434821@qq.com
* @description:返回的json对象
*/
public class AjaxResult {
private static final String OK = "ok";
private static final String ERROR = "error";
private boolean isError = false;
private String msg = OK;
public AjaxResult success() {
return this;
}
public AjaxResult failure() {
isError = true;
msg = ERROR;
return this;
}
public AjaxResult failure(String message) {
isError = true;
msg = message;
return this;
}
public boolean getIsError() {
return isError;
}
public void setIsError(boolean isError) {
this.isError = isError;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
CommonExceptionAdvice.jave,修改了返回的http状态
package com.jege.spring.boot.exception;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;