Relative path and absolute path problem for JSP page reference __js

Source: Internet
Author: User

The introduction of the jquery plugin in the JSP page is mainly the path problem introduced below, there are three ways:

1 . Create the JSP file directly under the Wetroot, put the jquery-1.7.js into a new folder: as shown:

The code to introduce jquery in index.jsp is: in the head [JavaScript] view plain copy print? 2 Create a new folder under Webroot Jsp,jquery-1.7.js put it under a new folder: Figure:
The code to introduce jquery into myname.jsp is: [JavaScript] view plain copy print? 3. Useful but not recommended solution fill in the following code at the top of the JSP file
When you introduce jquery, fill in the following code:
[JavaScript] view plain copy print? <script type= "Text/javascript" src= "<%=basepath%>/plugins/jquery/jquery-1.7.js" > the file structure at this time is like 2.

Reference source above: http://blog.csdn.NET/zjplovemm/article/details/21109109

Of course, you can also directly introduce an absolute path.

But today I encountered a problem, I used all the above methods to introduce failure, return 404 error.

Why , why? Later remembered that I use is SPRINGMVC, in the configuration time may affect to the static file use, like JS, CSS.

So I checked, and one of my brothers met the same problem as me: http://www.cnblogs.com/dscs/p/5043993.html

According to his method,

Add in SPRINGMVC configuration file

<mvc:annotation-driven/>

<mvc:default-servlet-handler/>

It's OK.

Problems to consider overall 、、、 will not be affected by other issues


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.