[b]web.xml配置[/b]
[b]spring-mvc.xml配置[/b]
[b]spring-mvc-servlet.xml配置[/b]
[b]BulletionListAction.java配置[/b]
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc.xml,
/WEB-INF/spring-mvc-servlet.xml</param-value>
</context-param>
<!—servlet-name必须和context-param指定的xml相同 -->
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
[b]spring-mvc.xml配置[/b]
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="bulletinList.do">bulletionListAction</prop>
<prop key="hello.do">helloWorldController</prop>
</props>
</property>
</bean>
<bean id="bulletionListAction" class="com.controller.BulletionListAction"></bean>
<bean id="helloWorldController" class="com.test.HelloWorldController"></bean>
[b]spring-mvc-servlet.xml配置[/b]
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
</bean>
[b]BulletionListAction.java配置[/b]
public class BulletionListAction implements Controller{
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
System.out.println("BulletionListAction执行成功");
return new ModelAndView("index.jsp");
}
}