第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

春天的MVC。為什么從 JSP 頁面看不到資源?

春天的MVC。為什么從 JSP 頁面看不到資源?

MMTTMM 2021-11-11 15:50:45
我有簡(jiǎn)單的 spring mvc 應(yīng)用程序。我嘗試向我的應(yīng)用程序添加類似靜態(tài)資源的 CSS,但我的 jsp 頁面找不到它。我的jsp頁面是這樣的:    <html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <title><fmt:message key="app.title"/></title>        <link rel="stylesheet" href="/resources/css/style.css">    </head>    <body>         ..................................................................    </body>    </html>另外我的 spring-mvc 上下文是這樣的:<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:context="http://www.springframework.org/schema/context"   xmlns:p="http://www.springframework.org/schema/p"   xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans"   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd   http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><mvc:annotation-driven/><mvc:resources mapping="/resources/**" location="/resources/"/><context:component-scan base-package="ru.javawebinar.**.web"/><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"      p:viewClass="org.springframework.web.servlet.view.JstlView"      p:prefix="/WEB-INF/jsp/"      p:suffix=".jsp"/>我的資源位于:
查看完整描述

2 回答

?
皈依舞

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超3個(gè)贊

你在使用 JSTL 嗎?如果是這樣,你可以包括這樣。

 <link href="<c:url value="/resources/css/style.css" />" rel="stylesheet">

另一種方法是:

<link href="${pageContext.request.contextPath}/resources/css/style.css" rel="stylesheet" >



查看完整回答
反對(duì) 回復(fù) 2021-11-11
?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

嘗試以下更改:


在 spring-web-config.xml 中:


<mvc:resources mapping="/resources/**" location="/resources/css/"/>

在您的 jsp 文件中:


<link href="<c:url value="/resources/css/style.css" />" rel="stylesheet">

更新:


對(duì)于 Spring,您可以在 *.jsp 文件中嘗試:


<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<!DOCTYPE html>

<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title><fmt:message key="app.title"/></title>

    <spring:url value="/resources/css/style.css" var="mainCss" />

    <link href="${mainCss}" rel="stylesheet" />

  </head>

  <body>

    ..................................................................

  </body>

</html>


查看完整回答
反對(duì) 回復(fù) 2021-11-11
  • 2 回答
  • 0 關(guān)注
  • 186 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)