web.xml に 2 つのサーブレット マッピングがあり、以下のサーブレットで参照するリソースのルート パスを設定したいと考えています。私の目標は、パス全体を JSP に入れる必要がないようにすることです。
例: (resources/admin/images) のイメージ パスを配置する代わりに、(/images) を配置できるようにしたい
ファイル構造は次のとおりです。
|_ admin
|_index.jsp
|_resources
|_images
|_views
|_dashboard.jsp (file in which I want to use the scoped file paths)
サイト (localhost.com) のベースとなるルート スコープがあります。定義しようとしている管理者レベル (localhost.com/admin) にある別のスコープが必要です。
検索してみましたが、サーブレット マッピングに何を追加すればよいかわかりません。以下は私のweb.xmlです
<display-name>cr</display-name>
<description>cr</description>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
classpath:spring-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>cr</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/spring-controllers.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cr</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<servlet-name>cr</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>admin</servlet-name>
<jsp-file>/resources/admin/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>admin</servlet-name>
<url-pattern>/admin/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>15</session-timeout>
</session-config>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>