In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article to share with you is about Spring 3.0.5 MVC exception handling is how, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.
SimpleMappingExceptionResolver
Simple, clear, sufficient, mapping between exception type and view, any custom exception type can be mapped here and error page, granular enough
springmvc.xml
XML code
redirect:/error.jsp? flag=BaseServiceException prop> redirect:/error.jsp? flag=RuntimeException prop> props> property> bean>
Spring 3 adds an exception handler annotation to the Control class.
Java code
@RequestMapping("exception") public void throwException() { throw new RuntimeException("This is the runtime exception"); } @ExceptionHandler(Exception.class) public @ResponseBody String handleException(Exception ex) { return ex.getMessage(); }
@ExceptionHandle can also be abstracted into BaseControl, but @ExceptionHandle will not work if SimpleMappingExceptionResolver is used
HandlerExceptionResolver
Custom exception implementation
Java code
public class WebExceptionResolver implements HandlerExceptionResolver { public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object object, Exception e) { HttpSession session = request.getSession(); session.getId(); //exception handling return null; } }
springmvc.xml
XML code
The above is how Spring 3.0.5 MVC exception handling is, Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.