外部の css/js が jsp にロードされなかった理由を知りたいです。私の struts.xml コンテンツ:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<constant name="struts.action.extension" value=""/>
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="home" />
<action name="home">
<result name="success">index.jsp</result>
</action>
</package>
</struts>
私の web.xml コンテンツ:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Test</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>error404.jsp</location>
</error-page>
</web-app>
このコードを使用してcssをjspにロードします
<link rel="stylesheet" type="text/css" href="../style/css/style.css"/>
私もこのコードを使ってみます
<link rel="stylesheet" type="text/css" href="<s:url value="/style/css/style.css"/>"/>
でも、jspに画像を表示したいときにエラーが発生します
<img src="<s:url value="/style/images/icon/car.png"/>" />
これの何が問題なのか、原因はこのコード (web.xml) かどうか
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
ご回答ありがとうございます。