浏览器无法使用JSP和servlet访问css,jquery资源

时间:2017-03-14 11:27:27

标签: java css jsp

我正在尝试使用以下示例添加css和jquery资源:http://www.codejava.net/coding/jsp-servlet-jdbc-mysql-create-read-update-delete-crud-example

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<!--     <script src="app-ajax.js" type="text/javascript"></script> -->
<!--     <link rel="stylesheet" href="css/mybook.css" type="text/css" /> -->
    <base href="">
    **<script src="${pageContext.request.contextPath}/jquery-1.10.2.js"></script>
    <script src="${pageContext.request.contextPath}/app-ajax.js"></script>
    <link href="${pageContext.request.contextPath}/mybook.css" rel="stylesheet"** type="text/css">

    <title class="book">Books Store Application</title>
</head>
<body>

的web.xml:

 <mime-mapping>    
            <extension>js</extension>        
            <mime-type>application/javascript</mime-type>        
        </mime-mapping>

        <mime-mapping>    
            <extension>css</extension>        
            <mime-type>text/css</mime-type>        
        </mime-mapping>
        <mime-mapping>    
            <extension>jpg</extension>        
            <mime-type>image/jpeg</mime-type>        
        </mime-mapping>

        <context-param>
            <param-name>jdbcURL</param-name>
            <param-value>jdbc:mysql://localhost:3306/bookstore</param-value>
        </context-param>

        <context-param>
            <param-name>jdbcUsername</param-name>
            <param-value>root</param-value>
        </context-param>

        <context-param>
            <param-name>jdbcPassword</param-name>
            <param-value>xxx</param-value>
        </context-param>

        <servlet>
            <servlet-name>ControllerServlet</servlet-name>
            <servlet- class>net.codejava.javaee.bookstore.ControllerServlet</servlet-class>
        </servlet>

        <servlet-mapping>
            <servlet-name>ControllerServlet</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>

使用Chrome开发者工具我注意到jquery-1.10.2.js,app-ajax.js和mybook.css都有html代码而不是javascript和css!

jquery-1.10.2.js: enter image description here

Google Chrome上的mybook.css:

enter image description here

这个问题是如何引起的?如何解决?

0 个答案:

没有答案