このような質問が Web 上 (特にここ) にたくさんあることは知っていますが、実際には何も役に立ちませんでした。spring mvc (spring バージョン 3.1.0.RELEASE) を使用しており、URL 経由で静的データにアクセスしたいと考えています。
私のパッケージ:
-src
--main
---resources
----public
inside public 私は、たとえば test.xml ファイルを持っています。
これは私のweb.xmlです
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/ApplicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/ServletContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
これは私の ServletContext.xml です
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/public/**" location="/resources/public/" />
このURL「localhost:8080/bmark-central/resources/public/test.xml」を入力すると、404が表示されます。コンテキストルート「localhost:8080/resources/public/test.xml」なしで試してみました。私のtest.xmlを取得できませんでした(404も取得しました)。何か間違ってマッピングしていますか?私はここで何かを逃していますか?前もって感謝します :)