Joyen.fu
日中则昃,月盈则食。
posts - 75,  comments - 0,  trackbacks - 0

web.xml配置:

<servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/springmvc/*.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

 

/WEB-INF/springmvc/路径下文件结构:

controller配置

servlet-controller.xml

1 <bean name="testController" class="com.controller.TestController">
2     <property name="testService" ref="testService"></property>
3     <property name="methodNameResolver" ref="parameterResolver"></property>
4 </bean>

 

servlet-forward.xml

 

URL handler处理配置
servlet-handler.xml

1 <bean id="firstHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
2     <property name="order" value="1"></property>
3     <property name="alwaysUseFullPath" value="true"></property>
4     <property name="mappings">
5         <props>
6             <prop key="test.do">testController</prop>
7         </props>
8     </property>
9 </bean>

 

拦截器配置
servlet-interceptor.xml

 

视图配置
servlet-resolver.xml

1 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
2     <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
3 </bean>
4 
5 <bean id="parameterResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
6     <property name="paramName" value="method"></property>
7 </bean>

 

posted on 2016-04-29 13:23  Joyen.fu  阅读(1107)  评论(0编辑  收藏