Spring MVC absolute URL problem

后端 未结 1 767
猫巷女王i
猫巷女王i 2021-01-02 09:17

Background

I am developing an application (with Spring MVC) with its base path as:

http://localhost:8080/myapplication/         


        
相关标签:
1条回答
  • 2021-01-02 09:45

    Use the JSTL c:url tag.

    <c:url value="/css/style.css" var="url" />
    <link rel="stylesheet" href="${url}" type="text/css" media="screen, projection">
    

    You can also use the pageContext to prefix the context path.

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" media="screen, projection">
    
    0 讨论(0)
提交回复
热议问题