JavaScriptJavaEE资源被解释为样式表,但使用MIME类型text/html为kendoUI传输
我在这里看到了几十个这样的问题,但没有解决我的问题。我正在一个非常简单的基本JavaEE动态web项目中测试剑道UI。我只有一个servelet和一个JSP。我使用<%@ include file="path" %>
只是为了利用这个标签。另外,我只使用servlet中的doGet
返回视图。但我还是会犯这样的错误:
我的CSS文件
Resource interpreted as Stylesheet but transferred with MIME type text/html
我的javascript文件
Uncaught SyntaxError: Unexpected token <
我使用的Pivotal服务器没有安全配置。我的IDE对所有类型的文件都使用默认编码(ISO拉丁语1)和(XML的UTF-8)
**重要症状:**当我在浏览器中使用http://localhost:8080/testKendoUI/resources/css/styles/kendo.default.min.css
或任何其他CSS或JS文件时,我会被重定向到index.jsp
而不是文件的代码
我在网上试过<mime-mapping>
。但它并没有解决这个问题
下面是我的代码和一些屏幕截图
网络。xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>com.kendoUI.controllers.dispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
调度程序servlet
package com.kendoUI.controllers;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/dispatcher")
public class dispatcher extends HttpServlet {
private static final long serialVersionUID = 1L;
public dispatcher() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.getServletContext().getRequestDispatcher("/WEB-INF/views/index.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
headerHTML。jsp
<!DOCTYPE html>
<html>
<head>
<title>My KendoUI Test App</title>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -->
<link type="text/css" rel="stylesheet" href="resources/css/styles/kendo.common.min.css"/>
<link type="text/css" rel="stylesheet" href="resources/css/styles/kendo.default.min.css"/>
<link type="text/css" rel="stylesheet" href="resources/css/bootstrap/css/bootstrap.min.css"/>
<script type="text/javascript" src="resources/js/jquery.min.js"></script>
<script type="text/javascript" src="resources/js/kendo.all.min.js"></script>
</head>
<body>
taglibs。jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="kendo" uri="http://www.kendoui.com/jsp/tags" %>
索引。jsp
<%@ include file="/WEB-INF/tags/taglibs.jsp" %>
<%@ include file="/WEB-INF/tags/headerHTML.jsp" %>
<div class="container">
<div class="row">
<h1>THIS IS MY TEST</h1>
<kendo:calendar name="calendar"></kendo:calendar>
</div>
</div>
<%@ include file="/WEB-INF/tags/footerHTML.jsp" %>
footerHTMl。jsp
</body>
</html>
错误屏幕截图
共 (0) 个答案