Spring MVCを使用してログインページとウェルカムページを持つ簡単なWebアプリケーションを作成しようとしています。コードは次のとおりです。警告:「spring」という名前のdispatcherservletでuri [/ Authentication /]を使用した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>
春-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 WARNING:HTTPが見つかりませんマッピング'spring'という名前のdispatcherservletのuri [/ Authentication /]でのリクエスト
マッピングが正常に表示されても、なぜこの警告が表示されますか?
[ようこそ、番号338](http://stackoverflow.com/search?q=is%3Aq+%22No+mapping+found+for+http+request+ + uri%22 +%22in + dispatcherservlet + +名前%22)。 – BalusC
あなたのアプリケーションにアクセスするためにあなたはどのURLを使用していますか? TestControllerクラスのパッケージですか? – amicoderozer