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
above two sentences are PHP document Content-type is set to "Text/xml", PHP document is set to "No-cache" to prevent the cache5 $time=Date(' Y-m-d h:i:s ', Time());6 7 $information= "XXXX";8 9 Ten Echo' //there must be, no words, nothing to lose. One Echo"$time. "; A //here the - Echo"$information. "; - Echo"//complete a pair with the person above the - -?>Since I was tested by the output system time, after the test was successful, I saw the
Beginner easy to get started with SSH-struts2 03 Data encapsulation, easy to get started with ssh-struts2
In this chapter, we can obtain data to see what is different from the previous chapter. There are also three
Struts2 interacts with Ajax data, and Struts2Ajax data
Preface:
Ajax requests are often used in projects. Today we will summarize the data transmission and interaction between foreground pages and background actions when
should has included the callback data, something likejQuery17209314005577471107_1335958194322({"foo":"bar"})
Here are the PHP code I used to achieve this, and which degrades if JSON (without a callback) is used:
$ret [ ' foo ' ] = "Bar" ; Finish (); function Finish () { header ( "Content-type:application/json" ); if ( $_get [ ' callback ' ] { print $_get [ ' callback ' ]. "(" ; } print json_encod
Struts2 using Ajax
Similar to file downloads, the result type needed to be configured in Struts.xml is stream.
Note Two properties contenttype and InputName,Where InputName corresponds to the value inputstream the property in action.The other configurations are generic configurations, and there is no difference.Let's look at the configuration in action
public class Xxxaction extends actionsupport{
p
last night encountered a bug, is the AJAX call Struts2 inside the method to obtain the JSON problem, although the problem is not solved, but a variety of Baidu, after the discovery of Stuts2 and Ajax interactive understanding and deep. One, if you set the action to return the result as a JSON typeFor example, if you want this action to return the result as JSON,
The main implementation steps are as follows:
1. JSP pages use scripting code to execute AJAX requests
2, action query out the need to return the data, and converted to JSON type pattern data
3. Configure Struts.xml Files
4, the page script accepts and processes the data
The key is as follows several points
1. Introdu
As a newbie, struts2 and jquery become more and more popular. These two days I summarized their methods for connecting to the sqlserver database. The test is feasible.
========================================================== ========================
Database Name: Test
Data Table Name: testtable, two fields (ID, text
() {7StringBuffer SB =NewStringBuffer ();8Sb.append (");9Sb.append (");TenSb.append ("); OneSb.append ("); ASb.append ("); -String string =sb.tostring (); - Try { theis =NewBytearrayinputstream (String.getbytes ("Utf-8")); -}Catch(unsupportedencodingexception e) { - //TODO auto-generated Catch block - e.printstacktrace (); + } - + return"OK"; A}The configuration file (which could have been written in the form of a wildcard, but in order to be clear i
The 1.action class introduces the Struts2 "Json-default" Interceptor stack@ParentPackage ("Json-default")// Wap_package inherits the Json-default@Namespace ("/")publicclassextends wapbaseaction {...[email protected] The result type is JSON and you can set the params@Action (value = "Creatresume", results = {@Result (name = Json,type=json, Params={root,result})})3.jquery serialized Form form forms using AJAX
parent domain
var mysrc = "http://a. Target URL. com:9000/myiframe.html";
document.domain = "Destination URL. com"; Critical code to elevate the domain to the root domain
$ ("Body"). Append ('
HTML code in IFRAME
Attention:
Only if the IFRAME is elevated to the root domain to communicate with the parent window, the ear document.domain instruction can only elevate the current domain to the current root domain, which is why the local hosts file must be modified, wh
Tags: jquery easyui struts2 DataGridBecause the Easyui DataGrid can display data from a database in a certain form in the foreground page data table, as long as it takes out a certain format of JSON data that is sent back from the background. Here, we use the
Assuming that the data is passed only through request, session, and application, there is no need to get the corresponding object to be able to pass the data, such as the following code:Scopeaction.java:Package Com.itheima.action;import Com.opensymphony.xwork2.actioncontext;public class Scopeaction {public String Execute () {/* * We do not pass
After mastering the interaction between Java objects and JSON, today's learning is how to use Ajax to request action and put back JSON characters, parsing JSON data in the foreground.
Step one: Use Ajax post to submit directly, write a post.jsp file
Then there is a JS (post.js) file corresponding to it, which is used to write the Post submission:
$ (function ()
page, and how to get it in ser.php.
Then write the data to the check box.Then write the data to the check box.30 points added, please lead the help.Your HTML code is not affixed to the fullis just the beginning of the code. What I want to do now is to query the relevant content via Ajax, and then submit it with
' = ' 2017-9-12 '),Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),Array (' title ' = ' = '
list above is defined as a character type, it will be converted into a character type if the int type is the same as the previous one. The preceding int is the type in the data tableCbNum.Items.AddRange (Numlist.toarray ());//Convert the data column to an array and then join the Cbnum, only accept arrays}private void Cbnum_selectedindexchanged (object sender, EventArgs e){Fieldlistlug.clear ();//continue t
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.