how to get data from database using ajax in struts2
how to get data from database using ajax in struts2
Learn about how to get data from database using ajax in struts2, we have the largest and most updated how to get data from database using ajax in struts2 information on alibabacloud.com
1, in the JSP page JS can use the JSP tag
var patientinfolist={patientid: "${session.patientid}"};var docdeplist=[], notypemap=["", "ordinary Number", "The attending doctor number", "the Deputy chief physician number", "the chief physician"];
idx" var= "list" items= "${docdeplist}" >docdeplist [${idx.index}]={doctorid: "${list.doctorid}", Departmentname: "${list.departmentname}"};
docdeplist is an array, in JS assignment is inside can be an object
patientinfolist is an object
2, if the valu
Label:1. First check the Chinese characters appear garbled location, so in action in the printf method to print the form submitted by the data to the console, found to be garbled.2. Then the problem is converted to solve the JSP form submitted by the Chinese data to the action in the case of garbled,3. Baidu a bit, found that because my Struts.xml file was created directly on the online copy of the template
Using AJAX to get background data, return JSON data, How to use it in the foreground?BackgroundC # code?
123456789101112131415
if(dataType=="SearchCustomer"){intID;if(Int32.TryParse(CustomerID,outID)){strings=GridComputer.GridCustomer.getCustomer(1,1,ID);if(s==null){context.Response.ContentType="text/p
/xml;charset=utf-8 ');
/ * Request Response content format when transferring data in XML format is text/xml*/
/*file_get_contents Get File contents * /
$xml = file_get_contents (' 01.xml ');
/ * Output XML content * /
echo $xml;
?>
3. AjaxHow to get the response data in XML format:Respon
Use js to declare an array. The object is in the jsp page (obtain json data from ajax ). For more information, see.
1. jsp labels can be used in jsp page js
Var patientInfoList = {patientId: "$ {session. patientId }"};VarDocDepList = [], NoTypeMap = ["", "General", "attending doctor", "Deputy Chief Physician", "Chief Physician"];
idx" var="list" items="${docDepList}">
DocDepList[
$ {Idx. index}]
DataTables is a jquery form plug-in. It is a highly flexible tool that allows you to add advanced interactivity to any HTML table.
Main function
Paging, Instant Search and sorting
Supports almost any data source: DOM, JavaScript, Ajax, and server processing
Supports different themes DataTables, JQuery UI, Bootstrap, Foundation
All kinds of extensions: Editor, Tabletools, Fixedcolumns ...
A rich variet
below to introduce the file upload non-Ajax submitted to the background data operation method, the specific details are shown below;
Get form data based on ID and then send AJAX request, get background return
certainly be sent to the server (even if there is no data to send).
Context
Type: Object
This object is used to set the context of the Ajax-related callback function. That is, let the this object in the callback function point (if this parameter is not set, then this points to the options parameter that is passed when the AJAX
JSON (JavaScript Object notation) is a lightweight data interchange format. The Jsonm file contains information about name and value. Sometimes we need to read JSON-formatted data files, which can be implemented in jquery using Ajax or $.getjson () methods.
The following is used to read the JSON data format informatio
How to replace the values in a page element with $.get (getdata.php,data,success, "json") to get the data in the database. Please tell me more about your ideas.
Reply content:
How to replace the values in a page element with $.get
//get Way to submit:Xmlhttp.open ("Get", "testservlet?name=" +username,true);
Xmlhttp.send (NULL);
Post-mode requested codeXmlhttp.open ("POST", "Testservlet", true);Post method requires you to set the HTTP request headers yourselfXmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded");Post method to send dataXmlhttp.send ("name=" +username);The method of the user's famous school exa
-informationdaoInformationdao inherits from Basedao, mainly to information this table to carry on the data operation, realizes to the database Java02_xp_table2 table's content query function. After executing the query, the data is encapsulated, encapsulated into a list, and the data is transformed by the
When you encounter the need to verify the existence of existing records in the database, you need to first use Ajax to submit the background action to determine whether there are records in the database, by returning JSON data, reception in the foreground, output results: For example, take the login user example:
There are two common approaches to browser-side cross-domain access:1, through the Ajax of jquery cross-domain, which is actually used in the JSONP way to achieve.JSONP is an abbreviation for English json with padding. It allows script tags to be generated on the server side to return to the client, that is, to dynamically generate JavaScript tags and to read data in the form of JavaScript callback.HTML cod
Asynchronous JavaScript and XML (Ajax ) are key technologies that drive a new generation of Web sites (popular terminology for Web 2.0 sites). Ajax allows data retrieval in the background without disturbing the display and behavior of the WEB application. Using XMLHttpRequest functions to get
, complete the processing of the specific business logic, and then object the data in the database, then package it as JSON;
Of course, this servlet must be registered with the configuration mapping in Web.xml.
public class Json extends HttpServlet {public void doget (HttpServletRequest request, httpservletresponse response) t
Hrows servletexception, IOException {doPost (request, response);
public
hibernate 4.3 Resolves a data problem that does not get the latest changes in the database by using get data because of a caching problemproblem processes and phenomena :Query a data list = "Manually update
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.