我写了一个包含多个控制器的Spring MVC应用程序。
在JSP上,我在表单中使用了action
:
<form id="createTableForm" method="post" name="createTable" action="${pageContext.request.contextPath}/saveTable" >
同时,相同的操作被映射到控制器中的一个方法:
@Controller
public class TableController implements TableConstants {
@RequestMapping(value="/saveTable")
public String saveTable(HttpServletRequest request,RedirectAttributes redirectAttributes) {
//...
}
}
在我的web.xml
中:
<context-param>
<description>Context name of the Application</description>
<param-name>contextName</param-name>
<param-value>W****</param-value>
</context-param>
<context-param>
<description>Database used for</description>
<param-name>databaseName</param-name>
<param-value>w*****</param-value>
</context-param>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>FilterChainProxy</filter-name>
<filter-class>com.abc.w****.configuration.FilterChainProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>FilterChainProxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
<jsp-config>
<taglib>
<taglib-uri>http://displaytag.sf.net</taglib-uri>
<taglib-location>/WEB-INF/tld/displaytag.tld</taglib-location>
</taglib>
</jsp-config>
我需要将特定控制器的URL映射包含在web.xml
文件中还是WebAppConfig
类中?
我已经在WebAppConfig
上注释了@Configuration、@ComponentScan和@EnableWebMVC。它有以下方法:
public UrlBasedViewResolver setupViewResolver() {
}
public MessageSource messageSource() {
}
public void addResourceHandlers(ResourceHandlerRegistry registry) {
}
public CommonsMultipartResolver multipartResolver() {
}
请给予建议。