package com.mkyong.web.controller;
import java.io.IOException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.mkyong.web.exception.CustomAjaxGenericException;
import com.mkyong.web.exception.CustomGenericException;
@Controller
public class MainController {
/* @RequestMapping(value = "/{type:.+}", method = RequestMethod.GET)
public ModelAndView getPages(@PathVariable("type") String type)
throws Exception {
if ("error".equals(type)) {
// go handleCustomException
throw new CustomGenericException("E888", "This is custom message");
} else if ("io-error".equals(type)) {
// go handleAllException
throw new IOException();
} else {
return new ModelAndView("index").addObject("msg", type);
}
}
*/
@RequestMapping(value = "view", method = RequestMethod.GET)
public ModelAndView view(){
throw new CustomGenericException("-1", "我是一个异常信息");
}
@RequestMapping(value = "ajax", method = RequestMethod.GET)
//@ResponseBody
public void getAjax() {
throw new CustomAjaxGenericException("-1", "我是一个异常信息");
}
/*
@ExceptionHandler(CustomGenericException.class)
public ModelAndView handleCustomException(CustomGenericException ex) {
ModelAndView model = new ModelAndView("error/generic_error");
model.addObject("errCode", ex.getErrCode());
model.addObject("errMsg", ex.getErrMsg());
return model;
}
@ExceptionHandler(Exception.class)
public ModelAndView handleAllException(Exception ex) {
ModelAndView model = new ModelAndView("error/generic_error");
model.addObject("errMsg", "this is Exception.class");
return model;
}*/
}

calm01
- 粉丝: 1
最新资源
- 【html手游源码】猜数字小游戏源码1.zip
- 【html手游源码】猜数字小游戏源码.zip
- 【html手游源码】猜数字小游戏源码2.zip
- 【html手游源码】测试你的性格味道.zip
- 【html手游源码】测你2014年能存多少钱.zip
- 【html手游源码】测一测你是那种菇凉.zip
- 【物流与通信网络优化】基于免疫算法的限量弧路由问题MATLAB实现:求解复杂组合优化问题的智能方法
- 【html手游源码】超级染色体.zip
- 【html手游源码】超级染色体小游戏.zip
- 【html手游源码】吃包子游戏源码.zip
- 【html手游源码】吃豆豆.zip
- 【html手游源码】吃豆豆游戏源码.zip
- 【html手游源码】吃月饼.zip
- 【html手游源码】戳泡泡.zip
- 【html手游源码】打飞机游戏.zip
- 【html手游源码】大力射手.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


