私が見る限り、これは正しく設定されているので、あなたが助けてくれることを願っています (しかし、私が間違っていることを証明してください)。
Spring 3 mvc プロジェクトを次のように構成しています。
web.xml
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/frontPage</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/myServlet-service.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
および myServlet-servlet.xml
<mvc:annotation-driven />
<context:component-scan base-package="my.path.to.controllers" />
<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>
「こんにちは」と言うだけの WEB-INF (WEB-INF/views ではない) 内に index.jsp があります (もともとは /frontPage に転送しようとしていました)。
ここで、コントローラーの URL (localhost:8080/myServlet/frontPage) を入力すると、コントローラーが機能し、ビューが表示されますが、最初の起動時に index.jsp ページではなく 404 が表示されます。index.jsp に先頭のスラッシュを追加しようとしましたが、違いはありません。
私はどこかで男子生徒の過ちを犯したに違いない. 誰かが私のためにそれを指摘できますか?
STS 2.9.1 サーブレット 2.5 で実行される Spring MVC 3.2 Tomcat 6
どうもありがとう。