私はTomcat Apacheサーバー上でjava springとjspを使用して "webdemo"という単純なWebアプリケーションを作成しています。私の目標は、プロジェクトのwarファイルからアセット(jsp、images、css、js)を分離し、tomcatのclasspathに格納してtomactの "common"フォルダに設定することです。Spring MVCアプリケーションからの別個のアセットファイル
webdemo-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<import resource="externalizationContext.xml"/>
<mvc:annotation-driven/>
<context:component-scan base-package="com.mckesson.voucher"/>
<mvc:resources mapping="/images/**" location="classpath:application-assets/webdemo/images/" />
<mvc:resources mapping="/scripts/**" location="classpath:application-assets/webdemo/scripts/" />
<bean id="couponBean" class="com.mckesson.voucher.model.CouponBean" scope="session">
<aop:scoped-proxy />
</bean>
<util:properties id="voucherProperties"
location="classpath:application-config/webdemo/externalization/webdemo.properties" />
<util:properties id="voucherEnvProperties"
location="classpath:application-config/webdemo/logging/loggingTags.properties" />
<util:properties id="voucherDBEnvProperties"
location="classpath:application-config/datasource/dataSource.properties" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="classpath:application-assets/webdemo/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
web.xmlの
<!-- General description of your web application -->
<display-name>McKesson webdemo</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dbContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>webdemo</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>webdemo</servlet-name>
<url-pattern>/home.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>webdemo</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>home.html</welcome-file>
</welcome-file-list>
<!-- Define the default session timeout for your application,
in minutes. From a servlet or JSP page, you can modify
the timeout for a particular session dynamically by using
HttpSession.getMaxInactiveInterval(). -->
<session-config>
<session-timeout>30</session-timeout><!-- 30 minutes -->
</session-config>
</web-app>
は、Tomcat上でホストされている300件のWebプロジェクトの近くにあり、最終的な目標は、それぞれに1つの場所ですべての資産は、それぞれの場所でありますtomcatの共通フォルダの下にあるWebプロジェクト。
ここにお手伝いいただければ幸いです。