Recently, an application using spring 1 MVC + hibernate 3 + dwr1 found a strange problem. Where dwr1 is used
When registering a user, determine whether the user exists. The Code is as follows:
DWR Configuration
But when running it, I always said that DWR could not find the userfacade method. I checked all the links again. That's all right. It's the same as the previous program code. I checked it for a lo
See some examples on the internet, for a simple three-level linkage, plus what struts, hibernate, and so on. This Ajax linkage does not know what the relationship with these frameworks, a small demo why the whole so big.
Today, I did an example of dwr+jsp.
Xml:
Copy Code code as follows:
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee
Http://java.sun.com/xml/ns/j2ee/web-app_2_
Believe that many projects, often file upload function bar.
Can I upload a file with Dwr? Simplifies the file upload process.
The answer, of course, is "certainly achievable".
The file upload function with DWR requires more than 3.0 versions.
OK, let's take a look at some basic things about file uploads.
1.html:
2.js
var files = dwr.util.getValue ("file");//This is the method in the Util.j
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
Generally, the method to obtain the value of the DWR method on the page is
Function Test (){
Dwrtest. Hello (function (data) {alert (data )})
}
It is difficult to return this value for your JavaScript test method. The DWR method returns the value after execution by calling the specified function. We often do this.
Function Test (){
VaR result;
Dwrtest. Hello (function (data) {result = data
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
-->
Adopt Dwr+ajax and Struts Development File Upload progress bar
writing a listener and related classes
Do not write yourself, the source code can be from
Http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example inside Download,
Download Address
Http://www.telio.be/blog/wp-content/uploads/2006/01/ajax-upload-1.0.war
After downloading, you need to unpack the package at the command line:
Jar XVF Ajax-upload-1.0.w
Two different ways
First, configure directly in the spring configuration file Applictioncontext
Second, separate dwr.xml file configuration
Test class:
Package com.test; public class Test {public string test (string name) {System.out.println ("---------"), return "Hello" + name + "!!!!!"; } }
The first way:
Applicationcontext.xml
DWR Forwarding with Org.directwebremoting.spring.DwrSpringServlet
Xml
Second Kind
Applicationcontext.xml (as with
A JavaScript error occurred while running HelloWorld
"Error: Object does not support this property or method"
In IE browser http://localhost:8000/Struts_Dwr/dwr/test/service can appear SayHelloWorld ();
can also run
The results of the operation are:
SayHelloWorld (); "Hello worldwanxuesi!"
But running with JavaScript in a JSP will report the above error, why.
The JSP code is as follows:
Solution:
To download a dwr.jar on the Internet if 2.0, size 494
1. PrefaceDWR provides a spring creator, and once the spring creator is used, DWR will be responsible for searching the spring container in the Web app and converting the beans in the SPRINGP container into a browser-callable object.2. Creating Java ClassesBelow we create a simple server processing class that will be configured in the Spring container.Package com.owen.dwr.dwr;/** * Server Processing class * @author owenwilliam 2016-5-8 * @version 1.0
Yesterday when using DWR encountered a session error error, after Google, in a foreigner's forum to see a solution,is configured in Web. Xml as follows:There's no problem with this addition.DWR Session Error
I. Correct Use of spring1. configuration of dwr. xmlCopy codeThe Code is as follows:CustomerManager is the Id registered by spring.2. Page callCopy codeThe Code is as follows:Ii. DescriptionIf the regular method used in the business logic class customerManagerImpl. java is not called by the static page, as shown inCopy codeThe Code is as follows:Public String test (){Return "hello ";}The following code cannot be executed:Copy codeThe Code is as follow
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 value and text. The value is the same as the t
The options in it are determined by the In the dwrutil package in DWR, two methods are provided for real-timeThe two methods are:Dwrutil. removealloptions (P1); // P1 is select element IDDwrutil. addoptions (P1, P2); // P1 is select element ID, P2 is Int or string Arrays
For example:Page ElementsFunction Update (){Demo. getnumbers (createlist, $ ("bigselect"). Checked );}
// Callback functionFunction createlist (data){Dwrutil. removealloptions ("numli
Nowadays, ssh combinations are widely used in Java EE applications, and Ajax technologies are everywhere. We generally use struts compliant with the MVC design pattern to regulateProgramStructure, use the excellent ORM Component hibernate to simplify database access operations, use the system adhesive spring to improve development efficiency, and use Ajax for asynchronous access to improve user experience. Today, a demo is a simplified HRMS (Human Resource Management System). On SSH, spring has
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: Missing Param or missing method convertThis is the
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.