用户提醒异常消息优化
This commit is contained in:
@@ -23,6 +23,8 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.io.PropertiesUtils;
|
||||
import com.jeesite.common.lang.ExceptionUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.mapper.JsonMapper;
|
||||
import com.jeesite.common.mapper.XmlMapper;
|
||||
@@ -184,7 +186,16 @@ public class ServletUtils {
|
||||
resultMap.put("result", result);
|
||||
resultMap.put("message", message);
|
||||
if (data != null){
|
||||
if (data instanceof Map){
|
||||
if (data instanceof Throwable){
|
||||
Throwable ex = (Throwable)data;
|
||||
String exMsg = ExceptionUtils.getExceptionMessage(ex);
|
||||
if (StringUtils.isNotBlank(exMsg)){
|
||||
resultMap.put("message", message + "," + exMsg);
|
||||
}else if (ObjectUtils.toBoolean(PropertiesUtils.getInstance()
|
||||
.getProperty("error.page.printErrorInfo", "true"))){
|
||||
resultMap.put("message", message + "," + ex.getMessage());
|
||||
}
|
||||
}else if (data instanceof Map){
|
||||
resultMap.putAll((Map<String, Object>)data);
|
||||
}else{
|
||||
resultMap.put("data", data);
|
||||
|
||||
@@ -23,7 +23,7 @@ if (isBlank(message)){
|
||||
|
||||
// 如果是异步请求或是手机端,则直接返回信息
|
||||
if (@ServletUtils.isAjaxRequest(request)) {
|
||||
if (@Global.getConfigToBoolean('error.page.printErrorInfo', 'true')
|
||||
if (@Global.getPropertyToBoolean('error.page.printErrorInfo', 'true')
|
||||
&& !@StringUtils.equals(message, "演示模式,不允许操作!") && ex != null){
|
||||
print(@ServletUtils.renderResult(@Global.FALSE, message, @ExceptionUtils.getStackTraceAsString(ex)));
|
||||
}else{
|
||||
@@ -49,7 +49,7 @@ else {
|
||||
href="http://jeesite.com">JeeSite ${@Global.getProperty('jeesiteVersion')}</a>
|
||||
</div>
|
||||
</div>
|
||||
<% if (@Global.getConfigToBoolean('error.page.printErrorInfo', 'true')
|
||||
<% if (@Global.getPropertyToBoolean('error.page.printErrorInfo', 'true')
|
||||
&& !@StringUtils.equals(message, "演示模式,不允许操作!")){ %>
|
||||
<div class="box mt20">
|
||||
${@StringUtils.toHtml(@ExceptionUtils.getStackTraceAsString(ex))}<br/>
|
||||
|
||||
Reference in New Issue
Block a user