3
Spring3 MVC - 控制器類正在調用,但不是控制器方法。Spring MVC - 未調用控制器方法
控制器:
package com.quizat.controller;
@Controller
public class QuizatController {
public QuizatController(){
System.out.println("in controller");
}
@RequestMapping("/")
@ResponseBody
public String home(Model model) throws Exception {
System.out.println("home is running");
return "success";
}
}
我的web.xml
<display-name>Spring3Example</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
我的調度員servlet.xml中
<mvc:annotation-driven />
<context:annotation-config />
<context:component-scan base-package="com.quizat" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix">
<value>/view/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
構造方法我的控制器的uctor運行。但是我在Controller中的方法沒有被調用。我可能犯的錯誤是什麼?