私のweb.xml
コンテンツは次のとおりです。
<servlet>
<servlet-name>springDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springDispatcher</servlet-name>
<url-pattern>*.htm</url-pattern> <!-- Why not put / instead of *.html? -->
</servlet-mapping>
<!-- ContextLoader -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/conf/applicationContext.xml
/WEB-INF/conf/applicationContext-data.xml
/WEB-INF/conf/applicationContext-service.xml
</param-value>
</context-param>
私applicationContext.xml
は:
<!-- Default ViewResolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<context:annotation-config />
<context:component-scan base-package="com.lftechnology.controller" />
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
/> -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="com.lftechnology.controller.EmployeeController">
<property name="employeeService" ref="employeeService" />
<property name="departmentService" ref="departmentService"></property>
</bean>
最後に、コントローラーは次のとおりです。
@Controller
public class EmployeeController {
EmployeeService employeeService;
DepartmentService departmentService;
//getters setters
@RequestMapping("/deleteEmployee.htm")
public String deleteEmployee(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//
return "redirect:viewEmployee";
}
@RequestMapping("/viewEmployee.htm")
public ModelAndView viewEmployee(HttpServletRequest request,
HttpServletResponse response) throws Exception {
Map<String, Object> model = new HashMap<String, Object>();
//
return new ModelAndView("viewEmployee", "model", model);
}
}
例外:
org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/springEmployeeAnotations/viewEmployee.htm] in DispatcherServlet with name 'springDispatcher'
このコードの何が問題なのかわかりません。少なくとも私にはすべてが正しいように思えます。viewEmployee
コントローラーのメソッドに入ろうとすると、例外が発生します。ヘルプはありますか?