2014-12-28 2 views
-1

동적 웹 프로젝트에 문제가 있습니다. 교축은
"리소스가 스타일 시트로 해석되었지만 MIME 유형이 text/html로 전송 됨"Java 웹 프로젝트 발행

WebContent
|
|
부트 스트랩
CSS를
JS
WEB-INF
|
|

<!DOCTYPE html> 
<html> 
<head> 
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css"/> 
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-theme.css"/> 
<link rel="stylesheet" type="text/css" href="css/connection.css"/> 
<script type="text/javascript" src="${pageContext.request.contextPath}/js/register.js">  </script> 
<title>Jweb</title> 
</head> 
<body> 

모든 CSS가 적용되지 않으며, 크롬의 콘솔에서 나는이있다 : connection.jsp


그런 다음 connection.jsp에 나는이 만들

Resource interpreted as Stylesheet but transferred with MIME type text/html: 
"http://localhost:8080/jweb/bootstrap/css/bootstrap-theme.css". localhost/:10 
Resource interpreted as Stylesheet but transferred with MIME type text/html:   "http://localhost:8080/jweb/bootstrap/css/bootstrap.css". localhost/:9 
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/jweb/css/footer.css". localhost/:11 
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/jweb/css/header.css". localhost/:12 
Resource interpreted as Script but transferred with MIME type text/html:  "http://localhost:8080/jweb/js/jquery.js". localhost/:14 
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/jweb/js/bootstrap.js". localhost/:15 
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/jweb/css/connection.css". 

웹. xml :

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> 
<jsp-config> 
<jsp-property-group> 
<url-pattern>*.jsp</url-pattern> 
<include-prelude>/WEB-INF/taglibs.jsp</include-prelude> 
</jsp-property-group> 
</jsp-config> 
</web-app> 

나는 2 일 전에이 문제를 해결하려고 노력하지만 여전히 그 위에. 해결할 수 있습니까?

<mime-mapping> 
    <extension>css</extension> 
    <mime-type>text/css</mime-type> 
</mime-mapping> 

일예 :

+0

그래도이 설정을 어디에서해야하나요? 나는 콘텐츠 유형이 "text/css"로 설정되었지만 작동하지 않는 을 추가하려고했습니다. 내 서블릿에 콘텐츠 형식 속성을 설정하려고했습니다. 그리고 그것을 해결하는 다른 방법 (인터넷에있는 모든 해결책)이 있지만 아무도 작동하지 않습니다. –

+0

웹 서버 설명서를 참조하십시오. 그것은 서버 소프트웨어에 따라 다릅니다. –

+0

서버 유형 (tomcat, glassfish, jboss) 및 게시 web.xml –

답변

0

빠른 "마임 매핑의 web.xml"검색은 당신이 당신의 web.xmlmime-mapping 요소를 사용하는 거라고 제안 (닫는 </web-app> 줄 앞에 바로 새로운 라인) :

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> 
<jsp-config> 
<jsp-property-group> 
<url-pattern>*.jsp</url-pattern> 
<include-prelude>/WEB-INF/taglibs.jsp</include-prelude> 
</jsp-property-group> 
</jsp-config> 
<mime-mapping> 
    <extension>css</extension> 
    <mime-type>text/css</mime-type> 
</mime-mapping> 
</web-app> 
+0

답장을 보내 주셔서 감사합니다. 나는 그것을 만들었지 만 여전히 효과가 없습니다. 이 수술을할까요? –

+0

@ JérômeCampeaux : 내가 아는 한 그게 모두 필요한 것입니다. 서버 등을 다시 시작해야합니다. –

+0

예. 서버를 다시 시작하고 Chrome 개발자보기에서 동일한 MIME 문제를 볼 수 있습니다. –

0

다음은 작업을 시도하기 위해 샘플의 web.xml입니다.

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     version="3.0"> 

       <servlet> 
        <servlet-name>welcome</servlet-name> 
        <jsp-file>index.jsp</jsp-file> 
        <load-on-startup>1</load-on-startup> 
       </servlet> 

       <servlet-mapping> 
        <servlet-name>welcome</servlet-name> 
        <url-pattern>/*</url-pattern> 
       </servlet-mapping> 

       <jsp-config> 
        <jsp-property-group> 
         <url-pattern>*.jsp</url-pattern> 
         <include-prelude>/WEB-INF/taglibs.jsp</include-prelude> 
        </jsp-property-group> 
       </jsp-config> 

</web-app> 
+0

서블릿 매핑 원인을 사용하지 않았습니다. 내 서블릿에서 @WebServlet ("/")을 사용했습니다. 이걸 만들면 설명 사이의 충돌에 대한 오류가 있습니다. –

관련 문제