Failed to introduce js and css files in jsp files, jscss

Source: Internet
Author: User

Failed to introduce js and css files in jsp files, jscss

I recently set up a project that fails to introduce js and css files in jsp. The cause of failure is the absolute path and relative path:

File structure:

Jsp code:

<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib uri="https://java.sun.com/jsp/jstl/core" prefix="c"%><%    String path = request.getContextPath();    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";    System.out.println(basePath);%>
<Script type = "text/javascript" src = "$ {basePath} assets/js/jquery/jquery-3.2.1.js"> </script> The absolute path used in the process fails to be introduced, and modification to the relative path also fails.

Solution:

In browser developer mode, 404 error is reported when a static file is introduced, so the resource cannot be accessed,

You need to configure the static resource directory in the springmvc. xml file:

 
 

Then OK.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.