Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

jsf - location of jquery.js file

I have created a sample jsf application, and am trying to use jquery. In what directory should the jquery.js file be located? web-inf? src? I downloaded the .js file, but it does not seem to be working. I'm not sure where it should be.

I have updated my code to point to the googleapis, but it still does not work:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">
        $(document).ready(function(){
            $("#p1").mouseenter(function(){
                alert("You entered p1!");
            });
        });
    </script>
    <p id="p1">Enter this paragraph.</p>
</h:body>

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can keep it anywhere as long as you give correct path to the file. But try to keep it away from the WEB-INF directory, keep only private file under that directory (files which are not directly accessible to users).

If you have a web-content directory, keep the jquery file under web-contentjs directory, so that you can access it via <path-to-your-app>/js/jquery.js.

But if you can try to use a CDN version of the file as given in the download section of jQuery. You can use either Google or Microsoft CDNs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...