Results 1 to 2 of 2

Thread: How to handle exception in handlerequest controller

  1. #1

    Default How to handle exception in handlerequest controller

    Hi,

    I am very new to spring framework.So i am having an doubt with how to use exception in handlerequest method.so please help me....


    Regards

    Developer

  2. #2
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    Hi ,

    You could use the following

    Code:
    org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
    usage is as follows
    Code:
    <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    		<property name="exceptionMappings">
    			<props>
    				<prop key="org.springframework.dao.DataAccessException">dataAccessFailure</prop>
    				<prop key="org.springframework.transaction.TransactionException">someother page</prop>
    			</props>
    		</property>
    	</bean>
    you should have a view resolver capable of resolving the values mentioned above "dataAccessFailure"

    another way is you could otherwise catch the exception in the controller and return a modelAndView yourself.

    but by the way why are you using controller?
    you should look at abstractcontroller, simpleformcontroller and so on
    Sami

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •