这个主题几乎说明了一切。如何自动修复 jsp 页面,以便将相对 URL 映射到上下文路径而不是服务器根目录?也就是说,例如
<link rel="stylesheet" type="text/css" href="/css/style.css" />
如何以将 css 映射到my-server/my-context/css/style.css
而不是的方式进行设置my-server/css/style.css
?除了将上述所有行更改为
<link rel="stylesheet" type="text/css"
href="<%= request.getContextPath() %>/css/style.css" />