[Spring] AbstractController

* AbstractController

– Abstract Class implemented Controller interface

– Return ModelAndView after process client’s request

– In controller inherited AbstractController, it only requires to implement handleRequestInternal method.

<?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- HandlerMapping -->
     <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
         <property name="mappings">
                 <prop key="/listAbsCont.sp">listAbstractController</prop>

    <!-- ViewResolver -->
     <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
         <property name="viewClass">
         <property name="prefix">
         <property name="suffix">

    <bean id="listAbstractController" class="controller.ListAbstractController">
        <property name="supportedMethods" value="GET"></property>



package controller;

import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.AbstractController;

public class ListAbstractController extends AbstractController {

     protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

         String param1 = request.getParameter("param1");

        //implement your require

         ModelAndView modelAndView = new ModelAndView();
         modelAndView.addObject("aaa", "bbb");

        return modelAndView;

Properties of AbstractController

Property Default Description
supportedMethod GET, POST HTTP method that conroller support
requirSession false Set whether require HTTPsession for processing request.
Exception occures when HttpSession doesn’t exist
cacheSeconds -1 cache header value for response in unit – second
0 – header doesn’t have  executing cache
-1 – doen’t have cache related header.
> 0 – include corresponding value in cache header

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s