DelMobilecardsController --- 删除操作Contorler
ListMobilecardsController --- 查询操作Contorler
无论 删除是否成功 还是失败,都会跳转到查询 Contorler去。
删除操作失败,会抛出异常,如何把异常信息传给ListMobilecardsController?
Ctorller 1(删除操作):
@Controller
public class DelMobilecardsController
{
private static final Logger logger = LoggerFactory.getLogger(DelMobilecardsController.class);
@RequestMapping(value = "/delMobilecards.action", method = RequestMethod.POST)
public ModelAndView delMobilecardsAction(@RequestParam(value = "id", required = false)
Long[] ids)
{
ModelAndView modelAndView = new ModelAndView("mobilecard/listMobilecards");
try
{
MobilecardService mobilecardService = (MobilecardService) BSSBeanFactory
.getBean(MobilecardService.BEAN_NAME);
mobilecardService.delMobilecards(ids);
}
catch (DtuException e)
{
logger.error(e.getErrorCode(), e);
BindingResult bindingResult = new BindException(e, "");
bindingResult.reject(e.getErrorCode());
modelAndView.addObject(bindingResult.getModel());
}
return modelAndView;
}
}
Ctorller 2(查询操作):
@Controller
public class ListMobilecardsController
{
@RequestMapping(value = "/listMobilecards.action", method = RequestMethod.GET)
public ModelAndView listMobilecardsAction(@RequestParam(value = "curPage", required = false)
Long curPage)
{
ModelAndView modelAndView = new ModelAndView("mobilecard/listMobilecards");
if (null == curPage)
{
curPage = 1l;
}
Pager pager = new Pager();
pager.setCurPage(curPage);
MobilecardService mobilecardService = (MobilecardService) BSSBeanFactory.getBean(MobilecardService.BEAN_NAME);
mobilecardService.findMobilecardsByPager(pager);
modelAndView.addObject("pager", pager);
return modelAndView;
}
}
ListMobilecardsController --- 查询操作Contorler
无论 删除是否成功 还是失败,都会跳转到查询 Contorler去。
删除操作失败,会抛出异常,如何把异常信息传给ListMobilecardsController?
Ctorller 1(删除操作):
@Controller
public class DelMobilecardsController
{
private static final Logger logger = LoggerFactory.getLogger(DelMobilecardsController.class);
@RequestMapping(value = "/delMobilecards.action", method = RequestMethod.POST)
public ModelAndView delMobilecardsAction(@RequestParam(value = "id", required = false)
Long[] ids)
{
ModelAndView modelAndView = new ModelAndView("mobilecard/listMobilecards");
try
{
MobilecardService mobilecardService = (MobilecardService) BSSBeanFactory
.getBean(MobilecardService.BEAN_NAME);
mobilecardService.delMobilecards(ids);
}
catch (DtuException e)
{
logger.error(e.getErrorCode(), e);
BindingResult bindingResult = new BindException(e, "");
bindingResult.reject(e.getErrorCode());
modelAndView.addObject(bindingResult.getModel());
}
return modelAndView;
}
}
Ctorller 2(查询操作):
@Controller
public class ListMobilecardsController
{
@RequestMapping(value = "/listMobilecards.action", method = RequestMethod.GET)
public ModelAndView listMobilecardsAction(@RequestParam(value = "curPage", required = false)
Long curPage)
{
ModelAndView modelAndView = new ModelAndView("mobilecard/listMobilecards");
if (null == curPage)
{
curPage = 1l;
}
Pager pager = new Pager();
pager.setCurPage(curPage);
MobilecardService mobilecardService = (MobilecardService) BSSBeanFactory.getBean(MobilecardService.BEAN_NAME);
mobilecardService.findMobilecardsByPager(pager);
modelAndView.addObject("pager", pager);
return modelAndView;
}
}
异常传递,最简单的做法就是放Model中,当普通对象传吧。