I have written a Spring MVC application with multiple controllers.
On the JSP, I have the action
on the form:
<form id="createTableForm" method="post" name="createTable" action="${pageContext.request.contextPath}/saveTable" >
and the same action is mapped to a method in the Controller:
@Controller
public class TableController implements TableConstants {
@RequestMapping(value="/saveTable")
public String saveTable(HttpServletRequest request,RedirectAttributes redirectAttributes) {
//...
}
}
And in my 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>
Do I need to include the URL mapping to that particular Controller in the web.xml
file or in the WebAppConfig
class?
I have the WebAppConfig
annotated with @Configuration, @ComponentScan and @EnableWebMVC. It has the following methods:
public UrlBasedViewResolver setupViewResolver() {
}
public MessageSource messageSource() {
}
public void addResourceHandlers(ResourceHandlerRegistry registry) {
}
public CommonsMultipartResolver multipartResolver() {
}
Please advise.
The
@RequestMapping
annotation could be applied to the controller class. In this case all the methods in this class will derive the defaults from the class annotation and the implementation could override it.