我有一个Spring MVC应用程序。实施后我的控制器没有被调用。
虽然我的默认search.jsp正常打开
调用控制器的search.jsp中的代码是
<a href="maintenance"><input type="button" value="Maintenance" /></a>
当我点击维护按钮时,我收到404 Not found错误。
我的spring-servlet.xml
如下
<context:component-scan
base-package="org.lacare.frc.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="order" value="0" />
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"/>
<property name="order" value="1" />
</bean>
<mvc:view-controller path="/" view-name="search"/>
我的web.xml如下
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
我的控制器如下
package org.lacare.frc.controller;
@Controller
public class NavigationsController {
@RequestMapping(value="/maintenance", method = RequestMethod.GET)
public ModelAndView navigateToSearch() {
return new ModelAndView("application");
}