Spring MVC でもレスポンスのテスト
JSF
http://d.hatena.ne.jp/shin/20090119/p2
T2,Cubby
http://d.hatena.ne.jp/shin/20090118/p1
の続き。今度はSpring MVCだ。
コントローラクラス
public class SpringTestController extends AbstractController { public SpringTestController() { } protected ModelAndView handleRequestInternal( HttpServletRequest request, HttpServletResponse response) throws Exception { ModelMap map = new ModelMap(); map.put("message", "ほげほげ"); return new ModelAndView("index", map); } }
環境設定ファイル
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> <!-- Most controllers will use the ControllerClassNameHandlerMapping above, but for the index controller we are using ParameterizableViewController, so we must define an explicit mapping for it. --> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="index.htm">indexController</prop> </props> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> <!-- The index controller. --> <bean name="indexController" class="SpringTestController" /> </beans>
JSPは「${message}」がはいってるやつを用意。XMLもNetBeansの初期テンプレートから少しいじっただけ。
アノテーション使わない一番シンプルなコントローラでやってみた。Spring MVC 1.x時代の懐かしい書き方だね。

さすがに軽い。JSFより10%程度軽いかな。
1000回にしても遅い値は現れないようだ。平均値は9msとわずかに下がる程度。