Java 在实现spring MVC时,没有发现任何处理程序错误
我一直试图从web上运行这个示例项目来学习spring mvc,但面临以下问题:Java 在实现spring MVC时,没有发现任何处理程序错误,java,spring,spring-mvc,servlets,Java,Spring,Spring Mvc,Servlets,我一直试图从web上运行这个示例项目来学习spring mvc,但面临以下问题: Mar 03, 2019 8:47:53 PM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/springmvcexample/employee-module] in DispatcherServlet with name 'sprin
Mar 03, 2019 8:47:53 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/springmvcexample/employee-module] in DispatcherServlet with name 'spring'
我点击的URL是:
以下是相关文件:
EmployeeController类
@Controller
@RequestMapping("/employee-module")
public class EmployeeController
{
@Autowired
EmployeeManager manager;
@RequestMapping(value = "/getAllEmployees", method = RequestMethod.GET)
public String getAllEmployees(Model model)
{
model.addAttribute("employees", manager.getAllEmployees());
return "employeesListDisplay";
}
}
Web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring Web MVC Hello World Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
SpringWebMVC HelloWorld应用程序
上下文配置位置
/WEB-INF/spring-servlet.xml
春天
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
1.
春天
/
spring-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.howtodoinjava.demo.*" />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
有人能帮忙吗
下面是已部署应用程序的服务器视图的屏幕截图
为什么不
http://localhost:8080/springmvcexample/employee-模块/getAllEmployees
?仍然获得相同的issue@ghostrider正如我所说,通过服务器视图发布带有已部署工件的对话框屏幕截图。@LppEdd发布的屏幕截图com.howtodoinjava.demo.*
不是有效的包名<代码>基本包需要一个包名。顺便说一句,您的控制器在这个软件包下吗?为什么不http://localhost:8080/springmvcexample/employee-模块/getAllEmployees
?仍然获得相同的issue@ghostrider正如我所说,发布带有已部署工件的对话框屏幕截图,通过服务器视图。@LppEdd发布了截图com.howtodoinjava.demo.*
不是有效的包名<代码>基本包需要一个包名。顺便说一句,你的控制器在这个软件包下吗?