我试图做一个简单的Web应用程序,其中有一个登录和一个欢迎使用Spring MVC的页面。代码如下:警告:没有映射发现与uri [/鉴定/]在名称为'春'的dispatcherservlet http请求
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 MVC Application</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
为spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.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.test"></context:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
Controller.java
@Controller
@RequestMapping("/Authentication")
public class TestController{
@RequestMapping(value="/")
public String Login(){
return "Login";
}
@RequestMapping(value="Authenticate", method=RequestMethod.GET)
public String Authenticate(){
//Authenticates and returns "Welcome"
}
}
项目名称为身份验证。/WEB-INF/jsp /下有Login.jsp和Welcome.jsp。
然而,当我试图运行项目,我收到HTTP状态404错误和以下警告:
org.springframework.web.servlet.PageNotFound noHandlerFound 警告:没有找到映射为HTTP请求与uri [/ Authentication /]在名为'spring'的dispatcherservlet中
即使映射看起来很好,我为什么会收到此警告?
[欢迎,编号338(http://stackoverflow.com/search?q=is%3Aq+%22No+mapping+found+for+http+request+与+ URI%22 +%22英寸+的DispatcherServlet +与+名称%22)。 – BalusC
您使用哪个网址访问您的应用程序?哪个是TestController类的包? – amicoderozer