Web-inf Directory of JSP How to reference the external file: Js,css and other __c#

Source: Internet
Author: User
Tags throw exception


In the case of non-spring MVC blocking "/":

Web-inf is protected and cannot be accessed directly
Here's how to fix it

<c:set value= "${pagecontext.request.contextpath}" var= "path" scope= "page"/>
<script type= "Text/javascript" src= "${path}/js/jquery-1.8.1.min.js" ></script>
<script type= "Text/javascript" src= "${path}/js/jquery.datepick.js" ></script>
<script type= "Text/javascript" src= "${path}/js/jquery.datepick-zh-cn.js" ></script>
<link type= "Text/css" href= "${path}/css/smoothness.datepick.css" rel= "stylesheet" >




First, there is no need for css/js/html to be placed under Web-inf.
eventually these will be displayed intact on the client side, so access security is not a problem at all. The

JSP is placed under Web-inf for the main reason that there are two

1. The ancient pattern will be the business logic, database connection and other sensitive information written in the JSP, the user directly access will have security problems.
This is no longer a problem in modern mode and should not be a problem.

2. JSP is running on the server side, and usually requires other program support-such as the background processing of data to allow JSP rendering and so on, the user directly access a meaningless, two will throw exception, these are wasted server resources.



Second, if you must put it under Web-inf. The
requires a servlet to forward, or read the file and write it on the response.

If it is spring, you can refer to the
http://static.springsource.org/spring/docs/current/spring-framework-reference/html/ mvc.html



17.15.6 Configuring serving of resources

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.