A strange problem was found recently. First, implementation feedback: After logging on to the system for a few minutes, click a function to display a white screen, close the browser, and log on to the system again. Click this function to display it normally.
Follow-up: After clicking this function several times, the entire browser will be displayed in white, and the entire system will be fine. You can use httpwatch to check whether a DWR request is w
I believe that many projects often have file upload functions.
Can I use DWR to upload files? Is the File Upload process simplified?
The answer is, of course, yes ".
To use DWR for file upload, you must have a version later than 3.0.
Now let's take a look at some basic operations on file upload.
1. html:
2. js
VaR files = DWR. util. getvalue ("fi
I started learning DWR today and encountered some problems. I always jumped out of session error.Problem description:The session error dialog box is displayed on the front-end page.The console outputs:11:58:53 org. directwebremoting. util. commonsloggingoutput ErrorSevere: A request has been denied as a potential csrf attack.Error message.
The request is rejected because of possible cross-site request forgeries (Cross-Site Request Forgery) attack
1. Introduce the dwr. jar package to lib in the project. 2. Configure dwr in web. xml as follows:
3. Create a dwr. xml, and the processing class configuration will be called in it, for example:
4. Then, introduce the call processing js class in the jsp to be called, as follows:
An example of calling js is as follows: function query () {var keyWor
JavaScript calls Java method--dwr steps
1. Download Dwr.jar directly to your project under the Webroot/web-inf/lib package;
2. Re-modify Web.xml
Add to
3. Build a Dwr.xml file and copy the file under Web-inf
Description: A Java class for each DWR agent needs to be placed in
for The Java class referenced in the JSP, usually the same as the class name . Create= represents what type of Java, andnew
Create Web projects, add Struts2 support, and import MySQL drivers, dwr files, and import jquery js files and Google logo images.1. Implement DAO, create a package named DAO under SRC, and create a class named Db.java in it, which is as follows:Package DAO;Import java.sql.Connection;Import Java.sql.DriverManager;Import Java.sql.ResultSet;Import java.sql.SQLException;Import java.sql.Statement;public class Db {static {try {Class.forName ("Com.mysql.jdbc
1. If dwr2 is used, remember to load the package under Lib in its download example. In this way, you cannot load only one DWR. jar package.
2. Web. xml configuration in DWR
DEBUG = true: allow http: // localhost: 8085/xxxx/DWR/index.html debugging.
3 Summary of DWR. xml
Import Lee. hellodwr;Import Le
DWR is easy Ajax for Java
DWR allows Javascript in a browser to interact with Java on a server and helps you manipulate web pages with the results. DWR makes it easy for you to Ajax enable your website.
DWR stands for Direct Web remoting.DWR is freely available as open source software (ASL version 2.0 ). it is straig
The Ajax framework DWR recently announced the release of the new version of DWR 2.0 M1 2.0 M1.
The DWR (Direct Web remoting) project is an open-source solution with the Apache license. It provides developers who want to use Ajax and XMLHttpRequest in a simple way. It has a set of JavaScript Functions, which simplifies the method for calling Java objects on the a
Date: 2009.05.07
Problem:
(1) Use DWR to implement three-layer cascade: function implementation, but the object in JS cannot be converted to the custom object videocateroy
(2) query JSP pages: How to Use STR returned by Js for SQL statements
1. Use DWR to implement layer-3 Cascade
1. Expected Implementation Structure Analysis
Grade 7
--- Last semester
------- Chinese
------- Mathematics
------- English
--
Matching Java objects with JavaScript objects
Public Class Remote {
Public void setperson (person p ){
This. Person = P;
}
}
And classes person looks like this:Public person {Private string name;Private int age;Private date [] appointments;// Getters and setters... be sure to add getter and setter}
// Then you can call this from JavaScript like this:VaR P = {Name: "Fred Bloggs ",Age: 42,Appointments: [new date (), new date ("1 Jan 2008")]};Remote. setperson (P );
Because setperson () is modifie
Map In the official documents of DWR, there is only one sentence for Map type ing.
...
However, this configuration is always problematic when processing the Map We have a function as follows:
Public Map In this case, we configure it in the dwr. xml file as follows:
Import java. util. Map;Import java. util. List;Import test. ReportDWRUtil;ReportDWRUtil. getParameterValues (String, Map ]>Running a program al
When using DWR to invoke ExtJS's Fileuploadfield to do file uploads, the upload operation cannot be implemented and the Engine.js file in the DWR corresponding jar package needs to be modifiedSet 1808 rows var clone =value.clonenode (True);1812 Row Value.parentNode.insertBefore (Clone,value); Comment outthrough var file = Dwr.util.getValue ("UploadFile"); Gets the value of the Fileuploadfield corresponding
1:jqueryHome: http://jquery.com/Design idea: A concise idea of the scheme, almost all operations are to choose the DOM element (with strong selector) to start, and then the operation of it (chaining and other characteristics).Advantages:The file is small, after compression code only more than 20 K, no compression code 94k.Selector and DOM manipulation convenience: jquery Selector vs. MooTools Element.Select
Add the following to DWR. xml:Code:
This will convert the error into a specific error description,As you can see on the console. (Of course, only the description is required, and the stack is not displayed ).Because Project traffic is too large to view logs, the specific description of the error displayed on the front end is very important.
After adding the above Code, if the pop-up interface is: Missin
Dwrutil. addoptions ()
DWR usually needs to fill in a list box, mainly the addoptions and removealloptions methods. If you need to maintain the list when updating, you usually need the following code:
var sel = DWRUtil.getValue(id);DWRUtil.removeAllOptions(id);DWRUtil.addOptions(id, ...);DWRUtil.setValue(id, sel);Dwrutil. addoptions (selectid, array)
The string of each element in the array represents the v
DWR in the global error message shows only an error pop-up dialog box, this display does not meet our specific output and capture the exception information we throw in the Java program, after research and testing, finally found a solution, examples are as follows:
Java class, Operations Adminuservo class public class Useroperater {public String Save (Adminuservo Adminuservo) throws exception{if ("". Equals (Adminuservo.getname ())) throw new Exception
The signatures section enables DWR to determine the Data Type stored in the collection. For example, in the following definition, we cannot know what type is stored in the list.
Public class Check{Public void setLotteryResults (List nos){...}} The signatures section allows us to imply what type DWR should use for processing. The format is easy for anyone who understands the generic type of JDK 5.
Import jav
1. Class
1.1 handle class
Package com. cloverworxs. uma. helper;
1.2 Bean class
Package com. cloverworxs. uma. helper;
2. Web. xml
3. DWR. xml
4. index. jsp
5. Use reverse Ajax from non-DWR servlet threads
List containers = containerutil. getallpublishedcontainers (getservletcontext ();
6. Notes
6.1 The required class library DWR. Jar commons-log
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.