Environment: Introducing the Juqery framework into a Java Web project
Tool: MyEclipse8.5
[Steps below]
A: Create a new Java Web Project Testjquery, creating a jquery folder under the Webroot directory
B: Download jquery-1.8.3.min.js into the jquery folder
C: Create a JSP page
<%@ page language= "java" import= "java.util.*" pageencoding= "iso-8859-1"%><%string path = Request.getcontextpath (); String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
Ps:jquery introduced path interpretation: jquery/jquery-1.8.3.min.js the current page test.jsp as coordinates in the current folder to find, because test.jsp and jquery folders are in the Webroot directory so do not need
'/', if add '/' means to find from the project root directory
D: Publish project, view test.jsp
You can see the tap button click me! can be taken to the value of the text box
Because
The text box is evaluated using the jquery syntax $ ("#test"). attr ("value"); Test is the ID of the text box
So
The jquery framework introduces success in this JSP page
The Ps:juqery framework can easily get the value of an object based on the object ID.
Steps to introduce a jquery framework into a JSP page for a Java project