当使用 __ajax=json 参数的时候 403 页面返回空字符的优化。
This commit is contained in:
@@ -362,7 +362,9 @@ public class ServletUtils {
|
|||||||
type = MediaType.TEXT_PLAIN_VALUE;
|
type = MediaType.TEXT_PLAIN_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (type != null) {
|
||||||
response.setContentType(type);
|
response.setContentType(type);
|
||||||
|
}
|
||||||
response.getWriter().print(string);
|
response.getWriter().print(string);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -505,10 +505,12 @@ web:
|
|||||||
# 使用智能参数接收器,同时支持 JSON 和 FormData 的参数接受
|
# 使用智能参数接收器,同时支持 JSON 和 FormData 的参数接受
|
||||||
smartMethodArgumentResolver: true
|
smartMethodArgumentResolver: true
|
||||||
|
|
||||||
# 使用 .json、.xml 后缀匹配视图(不推荐使用,推荐使用 favorParameter)
|
# 使用 .json、.xml 后缀匹配返回视图数据(Spring官方已不推荐使用)
|
||||||
favorPathExtension: false
|
favorPathExtension: false
|
||||||
# 使用 __ajax=json、__ajax=xml 参数名匹配视图
|
# 使用 __ajax=json、__ajax=xml 后缀匹配返回视图数据
|
||||||
favorParameter: true
|
favorParameter: true
|
||||||
|
# 使用 __ajax=json、__ajax=xml 请求头匹配返回视图数据
|
||||||
|
favorHeader: true
|
||||||
|
|
||||||
# MVC 拦截器
|
# MVC 拦截器
|
||||||
interceptor:
|
interceptor:
|
||||||
|
|||||||
@@ -6,11 +6,9 @@ var message = @ObjectUtils.toString(@request.getAttribute("message"));
|
|||||||
if (isBlank(message)){
|
if (isBlank(message)){
|
||||||
var ex = @ExceptionUtils.getThrowable(request);
|
var ex = @ExceptionUtils.getThrowable(request);
|
||||||
if (ex != null){
|
if (ex != null){
|
||||||
for (e in [ex, ex.cause!, ex.cause.cause!]){
|
var m = @ExceptionUtils.getExceptionMessage(ex);
|
||||||
if (@StringUtils.startsWith(e.message!, "msg:")){
|
if (isNotBlank(m)){
|
||||||
message = @StringUtils.replace(e.message!, "msg:", "");
|
message = m;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user