1. 添加config 配置類
package org.fh.config;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
/**
* 說明:錯誤例外攔截處理
* 作者:FH Admin
* from fhadmin.cn
*/
@Configuration
public class ExceptionConfiguration implements HandlerExceptionResolver {
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) {
ModelAndView mv = new ModelAndView(new MappingJackson2JsonView()); //回傳json
String exInfo = ex.toString().replaceAll("\n", "<br/>");
boolean status = exInfo.contains("Subject does not have permission");
if(status){
exInfo = "[沒有此頁面的訪問權限]" + exInfo;
}else {
System.out.println("==============例外開始=============");
ex.printStackTrace();
System.out.println("==============例外結束=============");
}
mv.addObject("exception", exInfo);
mv.addObject("result", "exception");
return mv;
}
}
2. 在邏輯類的方法上拋出例外 throws Exception,比如
/**洗掉
* @param out
* @throws Exception
*/
@RequestMapping(value=https://www.cnblogs.com/m13002622490/p/"/delete")
@RequiresPermissions("autograph:del")
@ResponseBody
public Object delete() throws Exception{
Map<String,String> map = new HashMap<String,String>();
String errInfo = "success";
//xxxx
map.put("result", errInfo); //回傳結果
return map;
}
3. 前端頁面接收例外結果
//發送 post 請求提交保存
$.ajax({
xhrFields: {
withCredentials: true
},
type: "POST",
url: httpurl+'xxxx/delete',
data: {tm:new Date().getTime()},
dataType:"json",
success: function(data){
if("success" == data.result){
}else if ("exception" == data.result){
alert("模塊例外"+data.exception);//顯示例外
}
}
});
?-----------------------------------------------------------------自定義表單
28. 定義模版:拖拽左側表單元素到右側區域,編輯表單元素,保存表單模版
29. 表單模版:編輯維護表單模版,復制表單模版,修改模版型別,預覽表單模版
30. 我的表單:選擇表單模版,編輯表單規則,是否上傳圖片、附件、開啟富文本、掛靠流程開關等
31. 表單資料:從我的表單進去可增刪改查表單資料,修改表單規則
32. 掛靠記錄:記錄表單資料和流程實體ID關聯記錄,可洗掉
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/458465.html
標籤:Java
上一篇:C++基礎01-類與物件
下一篇:ReadWriteLock讀寫鎖
