У меня есть каталог, содержащий несколько статических файлов (* .png, * .css и т. Д.).
Я подумал (возможно, по ошибке), что достаточно просто создать каталог в файле WEB-INF моего приложения, и я смогу получить доступ к файлам, просто ссылаясь на них по имени:
Пример:
<link rel="stylesheet" href="/static/styles.css" type="text/css">
Моя структура каталогов следующая:
+WEB-INF
|
+---static
|
+--styles.css
+--header.png
Мой web.xml выглядит следующим образом
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
version="2.4">
<display-name>myapp</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:com/example/myapp/spring/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
com.example.myapp.ContextListener
</listener-class>
</listener>
<!--
There are three means to configure Wickets configuration mode and they are
tested in the order given.
1) A system property: -Dwicket.configuration
2) servlet specific <init-param>
3) context specific <context-param>
The value might be either "development" (reloading when templates change)
or "deployment". If no configuration is found, "development" is the default.
-->
<filter>
<filter-name>wicket.myapp</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
</init-param>
</filter>
<filter>
<filter-name>wicket.session</filter-name>
<filter-class>org.apache.wicket.protocol.http.servlet.WicketSessionFilter</filter-class>
<init-param>
<param-name>filterName</param-name>
<param-value>wicket.myapp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wicket.myapp</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>wicket.session</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
</web-app>
Но ....
Это не работает, я просто получаю 404 - файл не найден при попытке доступа к ресурсам, содержащимся в «статическом» каталоге. Я что-то упускаю здесь?