浏览器在调用转发到JSP的servlet时无法访问/查找CSS、图像和链接等相关资源
<welcome-file>
index.jsp
<welcome-file>
HomeServlet
index.jsp
web/styles/default.css
.web/images/
.
<link href="styles/default.css" rel="stylesheet" type="text/css" />
<img src="images/image1.png" alt="Image1" />
更新1
header.jsp
HomeServlet
welcome-file
web.xml
:
<welcome-file-list> <welcome-file>HomeServlet</welcome-file></welcome-file-list>
web.xml
:
<servlet> <servlet-name>HomeServlet</servlet-name> <servlet-class>com.brianblog.frontend.HomeServlet</servlet-class></servlet><servlet-mapping> <servlet-name>HomeServlet</servlet-name> <url-pattern>/</url-pattern></servlet-mapping>
更新2<welcome-file>
/
<servlet-mapping> <servlet-name>HomeServlet</servlet-name> <url-pattern>/HomeServlet</url-pattern></servlet-mapping>
忽然笑