Announcement Announcement Module
Collapse
No announcement yet.
about handle exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • about handle exception

    hi everybody.

    i encountered some question when try the handle exception.
    i check the conf many times,but it also failed.

    HTML Code:
    <!--handle exception-->
    <bean name="exceptionResolver"
              class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" >
            <property name="defaultErrorView" value="defaultErrorView"/>          
            <property name="exceptionMappings">
                <value>
                  org.springframework.web.multipart.MaxUploadSizeExceededException=maxUploadSizeExceededView
                </value>
            </property>
        </bean>
    
    <bean id="internalPathMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver">
    <property name="suffix" value="Handler"/>
    </bean>
    
     <bean name="exceptionController" class="cn.yura.myaop.controller.ExceptionController">
            <property name="methodNameResolver" ref="internalPathMethodNameResolver"/>
            </bean>
    
    <bean id="urlMapping"
              class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <value>             
                    /exception/*.cs=exceptionController
                    /testException.cs=testException
                    /index.cs=index
                </value>
            </property>
        </bean>
    
    public class ExceptionController extends MultiActionController {
        public ModelAndView defaultErrorHandler(HttpServletRequest request,
                                                HttpServletResponse response) {
            return new ModelAndView("defaultErrorView");
        }
    
        public ModelAndView maxUploadSizeExceededHandler(HttpServletRequest request,
                                                    HttpServletResponse response) {
            return new ModelAndView("maxUploadSizeExceededView");
        }
    
    
    }
    
    public class IndexController extends AbstractController {
        protected ModelAndView handleRequestInternal(HttpServletRequest request,
                                                     HttpServletResponse response) throws Exception {
           // throw new NullPointerException();
            throw new MaxUploadSizeExceededException(1000000);
        }
    }
    
    the last part is views.properties
    
    #maxUploadsizeExceededView
    maxUploadSizeExceededView.class=org.springframework.web.servlet.view.JstlView
    maxUploadSizeExceededView.url=/views/exception/maxUploadSizeExceeded.jsp
    
    #errors
    defaultErrorView.class= org.springframework.web.servlet.view.JstlView
    defaultErrorView.url=/views/exception/defaultError.jsp
    there are some useful information.
    i use a test below and works fine.
    HTML Code:
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
            ApplicationContext ctx = new FileSystemXmlApplicationContext(
    "//home/yura/IdeaProjects/myAop/out/exploded/WEB-INF/myAop-servlet.xml");
    SimpleMappingExceptionResolver demo = (SimpleMappingExceptionResolver) ctx.getBean("exceptionResolver");
         //  SimpleUrlHandlerMapping handle=(SimpleUrlHandlerMapping)ctx.getBean("publicUrlMapping");
           return  demo.resolveException(request,response,null,new NullPointerException());
        }
    the display page is different from the one without setting the handle solver
    it is strange.
    for example :
    with setting handle solver
    HTML Code:
    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 1000000 bytes exceeded
    	cn.yura.myaop.controller.IndexController.handleRequestInternal(IndexController.java:14)
    	org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
    without the setting handle solver
    HTML Code:
    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 1000000 bytes exceeded
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    root cause
    
    org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 1000000 bytes exceeded
    	cn.yura.myaop.controller.IndexController.handleRequestInternal(IndexController.java:14)
    	org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
    the request /exception/defaultError.cs(*.cs) is well

    ps my version is 2.5.5.
    any comment is welcome

  • #2
    wow....
    it is a bug in 2.5.5

    my dear yestoday give to a bug.




    thanks for your reading.

    cheers
    yura

    Comment

    Working...
    X