Problem description:It is the simplest getting started demo of DWR. It is also written according to the Getting Started demo of DWR. However, the following problems occur during running.The session error dialog box is displayed on the front-end page.The console outputs:2007-5-29 11:58:53 org. directwebremoting. util. commonsloggingoutput ErrorSevere: A request has been denied as a potential csrf attack.Erro
, servletresponse res ){
Init ();
}
}
Import javax. servlet. genericservlet;
In the sessioncreated method, the ID of the current login user is put into the scriptsession. This ID is used to identify the push target during the subsequent push process.
Push method:
[Java]
View plaincopyprint?
/**
* Push to a specified user
* @ Param userid
* @ Param request
* @ Return
*/
Private void send (final string receiverid, final string MSG ){
Browser. withallsessionsfiltered (New scripts
We use DWR to invoke the remote method to involve the data conversion between JS and JAVA parameters and return values, for example:
The conversion between JS 123 and Java int or Integer, long
The conversion between JS "2009-06-23" and Java java.util.Date
Conversion between JS "[1,2,3]" and Java int[]
JS "{id:123, Name: ' Unmi '}" and Java Class person{int ID; Conversion between String name}
or more complex nested types ("{id:123, Name: ' Unmi ',
Here is an example of how DWR is configured in spring by passing an object.JSP page: var instructionouter = { id:1, name: ' MyName ' };//set sync Dwrengine.setasync (false); Instructionouterservice.checksameins (Instructionouter,function ( Date) {return;});D Wr.xml file: Dwr is applied in spring
Util.js contains useful function functions that are called on the client page and can be separated from DWR and duliying for your system.
The main functions are as follows:
1, $ () get the page parameter value
2, AddOptions and Removealloptions initialize the Drop-down box
3, Addrows and removeallrows fill the table
4, GetText get the value of the Text property
5, GetValue get form form value
6, GetValues get form multiple values
7, OnReturn
8, Selec
mentioned it in my blog. We can consider Lucene. I didn't pick up the book to learn it over the past few days. During the course of reading the book today, compass was mentioned in the book, downloaded. but I haven't read it yet. Let's talk about it later. however, it is troublesome to create an index on a local machine because disk sharing is not suitable for the dual-machine solution of the existing system. Do you want to store the index in the database? Or is there another storage? (Not yet)
1. Import Three jar packages:Commons-validator-1.1.4.jarJakarta-oro-2.0.8.jarDWR. Jar2. modify the configuration file of Web. xml3. Compile common Java background code4. Write the class to be exposed to the front-end into the DWR. xml configuration file.Make the following configuration under the allow node:5. test:You can enter the path under the project name in the browser to view all the methods that can be called at the front-end when classes confi
If you want to extract some strings from the item list, then fill them in the drop-down list.
For example, a sample Java program is as follows:
12345678
PackageOnlyfun. Caterpillar;Public ClassOption {PublicString [] getoptions (){// In fact, these strings are found from the information...Return NewString [] {"Liangge", "Mao Meimei", "mi puppy "};}}
In the response string column, you need to fill in the response to the drop-down list. Of course, first we need to develop this o
Now take a struts + Spring + DWR + ibatis environment is always depressed to die, the next struts2.0The package is dozens of trillion, several add up to more than 100 trillion. Now every plug-in is anxious to add all the functions to the inside, a few plug-ins between the jar packets repeated n times, if you do not know how to filter will lead to software products overweight.Recently spent some time, through the practice to summarize the following req
The script engine. js contains the core part of DWR. Generally, your application should include it.Util. JS is usually included, which contains some optional practical methods.Demo. JS is dynamically defined in DWR. It also contains a corresponding remote version called demo. java. If you seeThe following code:Demo. Method1 = function {callback, P0}Demo. method2 = function {callback}So we can see that the f
1. Configure multiple configuration files in DWR
If you need to use multiple DWR. XML, you can do this.
During configuration, config-XXXXX,
WEB-INF/dwr-user.xml
The previous Web project is already based on the Spring MVC framework and now needs to do a Dynamic Web page refresh feature, using DWR push Technology, server-side updates, immediately displayed on the Web page.
1. Import Dwr.jar Package
2. Configure the Web. xml file, and all the mappings are intercepted by the spring MVC controller and then forwarded by the controllers.
3. Configure the information about DW
Util. js contains some useful function functions for calling on the client page. It can be separated from dwr and independent camp is used in your system.The main functions are as follows:1. Get the page parameter value by $ ()2. addOptions and removeAllOptions3. addRows and removeAllRows Filling Table4. getText: Get the text property value5. getValue: Get the form value6. getValues obtains multiple form values.7. onReturn8. selectRange9. setValue10.
getdata.jsp
In fact, the use of DWR to get background data is very easy to achieve, but for how to set the browser dynamic refresh Access data is not very clear, according to the information on the Internet to find that the original this is simpler:
function Myshow (){Timer = Window.setinterval ("GetResult ()", 2000);}
This is a web project
The first is the Web. xml file.
Then there is the DWR configuration file DWR. xml located under // WEB-INF //
Then the index. jsp page is used to display the infinite provincial/municipal linkage effect.
City. Java
Package COM. jadyer. model;
Then, the DAO class operated directly with the Oracle database
Package COM. jadyer. dao;
Finally, the database script file
-- Oracle 11g
Spring MVC + DWR verify whether the user name exists. This is the most typical case.
1 In dwr2, note that the configured class name is different from that in dwr1.Changed from UK. Ltd. getahead to org. directwebremoting.New configuration1 2 3 4 5 6 7 8 9 2. You have to change the DTD.
3 DWR. xml
-->
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.