【问题标题】:JSP and Spring ApplicationJSP 和 Spring 应用程序
【发布时间】:2017-03-29 06:33:40
【问题描述】:

在我们的spring Application的其中一个JSP页面中,我们有一个链接

<link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css"></link>

当我们在本地环境中运行项目时,css 可以工作,但在不同的环境中却不能工作

在其他环境中的 CSS URL 被

<link rel="stylesheet" href="/myapp/css/jquery-ui.css">

当我们移除此下方的 App 名称(request.getContextPath()) 时

<link rel="stylesheet" href="/css/jquery-ui.css">

css 在其他环境中工作。

***1。 ***在本地系统中,以下 URL 运行良好。******

 <link rel="stylesheet" href="<%request.getContextPath()%>/css/bootstrap.min.css"></link>

当我们删除 ContexPath() 意味着 CSS 不起作用

<link rel="stylesheet" href="/css/bootstrap.min.css"></link>

如何在本地和其他环境中处理此问题?

【问题讨论】:

  • 请提供您使用 request.getContextPath() 在本地和不同服务器中获取的 URL

标签: css spring relative-path jsp-tags


【解决方案1】:

试试这个

<link type="text/css" href="<%=request.getContextPath() %>/resources/css/main.css" rel="stylesheet"/> 

【讨论】:

    猜你喜欢
    • 2012-09-30
    • 2020-01-22
    • 1970-01-01
    • 2018-11-07
    • 2015-10-08
    • 2019-03-12
    • 2023-01-25
    • 1970-01-01
    • 2017-01-01
    相关资源
    最近更新 更多