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

  • 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
    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

    Comment

    Working...
    X