mirror of https://gitee.com/stylefeng/guns
更新404页面,改为不渲染json,渲染html页面
parent
891e4e3f94
commit
aeefbfb84d
|
@ -1,5 +1,6 @@
|
|||
package cn.stylefeng.guns.config.web;
|
||||
|
||||
import cn.stylefeng.guns.core.beetl.CustomBeetlGroupUtilConfiguration;
|
||||
import cn.stylefeng.guns.core.error.CustomErrorAttributes;
|
||||
import cn.stylefeng.guns.core.error.CustomErrorView;
|
||||
import cn.stylefeng.guns.core.security.AuthJwtTokenSecurityInterceptor;
|
||||
|
@ -60,8 +61,11 @@ public class SpringMvcConfiguration implements WebMvcConfigurer {
|
|||
* @date 2020/12/16 15:47
|
||||
*/
|
||||
@Bean("error")
|
||||
public CustomErrorView error() {
|
||||
return new CustomErrorView();
|
||||
public CustomErrorView error(CustomBeetlGroupUtilConfiguration customBeetlGroupUtilConfiguration) {
|
||||
CustomErrorView customErrorView = new CustomErrorView();
|
||||
customErrorView.setUrl("/404.html");
|
||||
customErrorView.setGroupTemplate(customBeetlGroupUtilConfiguration.getGroupTemplate());
|
||||
return customErrorView;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
package cn.stylefeng.guns.core.error;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ErrorResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.util.ResponseRenderUtil;
|
||||
import org.springframework.web.servlet.View;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
import org.beetl.ext.spring.BeetlSpringView;
|
||||
|
||||
/**
|
||||
* 错误页面的默认跳转(例如请求404的时候,默认走这个视图解析器)
|
||||
|
@ -16,17 +8,11 @@ import java.util.Map;
|
|||
* @author fengshuonan
|
||||
* @date 2017-05-21 11:34
|
||||
*/
|
||||
public class CustomErrorView implements View {
|
||||
public class CustomErrorView extends BeetlSpringView {
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return "text/html";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Map<String, ?> map, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
||||
ErrorResponseData errorResponseData = BeanUtil.mapToBean(map, ErrorResponseData.class, true, CopyOptions.create().ignoreError());
|
||||
ResponseRenderUtil.renderErrorResponse(httpServletResponse, errorResponseData.getCode(), errorResponseData.getMessage(), errorResponseData.getExceptionClazz());
|
||||
return "text/html;charset=UTF-8";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue