<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>insert title here</title>
<body>
Refresh:
<br/>
<div id= "MyView2" >
<span> Please enter the title:</span>
<input v-model= "BookName"/>
</div>
<br/>
<table border= "1px" id= "MyView" >
<tr>
<th>ID</th>
<th> title </th>
<th> Price </th>
</tr>
<tr v-for= "book in Booklist" >
<td>{{book.id}}</td>
<td>{{book.name}}</td>
<td>{{book.price}}</td>
</tr>
</table>
</body>
<script src= "${pagecontext.request.contextpath}/js/vue.js" ></script>
<script src= "${pagecontext.request.contextpath}/js/jquery-3.2.1.min.js" ></script>
<script type= "Text/javascript" >
Booklist cannot be empty, otherwise it will fail with view binding
var clientinput = {bookname: '};//This JSON purpose is used for submission to server queries
var myViewModel2 = new Vue ({
El: ' #myView2 ',
Data:clientinput,
methods:{
Querybook:function () {
Enter the contents of the client $ (' #bookName '). Val ()
Assign a value to clientinput this JSON
Clientinput.bookname = $ (' #bookName '). Val ();
$.ajax ({
URL: ' 44.jsp ',
URL: ' Bookaction_querybook ',
Type: ' GET ',
Data:clientinput,
DataType: ' JSON ',
timeout:2000,
Success:function (Result) {
alert (result.booklist);
Mymodel.booklist = result.booklist;
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert (' Server busy, please do not speak dirty words, theoretically everyone is civilized people ');
alert (textstatus+xmlhttprequest.status);
}
});
}
}
});
var MyModel = {booklist:[]};
var Myviewmodel = new Vue ({
El: ' #myView ',
Data:mymodel
});
For the purpose of the function, in order to "reuse"
function GetData () {
Alert (11);
$.ajax ({
URL: "Bookaction_getallbook",//Backend API address
Type: ' GET ',//http:post/get
Data:postdata,//refers to parameters submitted to the backend by the client
DataType: ' json ',//server return type Text,json
timeout:2000,
Success:function (Result) {
Mymodel.booklist = result.booklist;
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert (' Server busy, please do not speak dirty words, theoretically everyone is civilized people ');
alert (textstatus+xmlhttprequest.status);
}
});
}
GetData ();
</script>
Use configuration in Vue.js (with the use of the SSH framework) {The rest of the code is ibid}