Example of combining DWR with spring
Applicationcontext. xml file
<Bean id = "hello" class = "com. zscqj. Common. Hello"> </bean>
Java class
Package com. zscqj. Common;
Public class Hello {
Public String say (string INFOR ){
Return "the message you sent is:" + infor;
}
}
JSP page:
<% @ Page Language = "Java" pageencoding = "UTF-8" %>
<SCRIPT type = 'text/JavaScript 'src = 'dwr/engine. js'> </SCRIPT>
<SCRIPT type = 'text/JavaScript 'src = 'dwr/util. js'> </SCRIPT>
<SCRIPT type = 'text/JavaScript 'src = 'dwr/interface/Hello. js'> </SCRIPT>
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>
<HTML>
<Head>
<Base href = "<% = basepath %>">
<Title> This is a test of DWR. </title>
<SCRIPT type = "text/JavaScript">
Function tijiao ()
{
VaR info = Document. All ["infor"]. value;
Alert (Info );
Hello. Say (Info, callback );
}
Function callback (data)
{
Document. All ["con"]. innerhtml = data;
}
</SCRIPT>
</Head>
<Body>
<Br>
<Center>
Haha, no address! The basepath on this page is: <% = basepath %> <br>
Haha, no address! The path on this page is: <% = PATH %> <br>
<Input type = "text" name = "infor">
<Input type = "button" value = "" onclick = "tijiao ()"> <br>
The content returned after submission is as follows:
<Br> <font color = "red"> <span id = "con"> </span> </font>
</Center>
</Body>
</Html>
Web. xml file:
<Servlet>
<Servlet-Name> DWR-invoker </servlet-Name>
<Servlet-class> UK. Ltd. getahead. DWR. dwrservlet </servlet-class>
<Init-param>
<Description> </description>
<Param-Name> debug </param-Name>
<Param-value> true </param-value>
</Init-param>
</Servlet>
<Servlet-mapping>
<Servlet-Name> DWR-invoker </servlet-Name>
<URL-pattern>/DWR/* </url-pattern>
</Servlet-mapping>
DWR. xml file:
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype DWR public "-// getahead limited // DTD direct Web remoting 2.0 //" http://getahead.org/dwr/dwr20.dtd ">
<DWR>
<Allow>
<! -- Resources not in this war file: Java. util. date -->
<Create creator = "Spring" javascript = "hello">
<Param name = "beanname" value = "hello"/>
</Create>
</Allow>
</DWR>
After configuration, the test runs and the following error occurs:
Info-retrieved system configuration file: Java. Io. bytearrayinputstream @ 1145cc
Info-creator 'pageflow' not loaded due to classnotfoundexception. This is only an problem if you wanted to use it. Cause: beehive/WebLogic creator not available.
Info-converter 'jdom 'Not loaded due to noclassdeffounderror. This is only an problem if you wanted to use it. Cause: ORG/JDOM/Document
Info-found hibernate3 class: org. hibernate. hibernate
Info-type 'org. JDOM. document' is not convertable due to missing converter 'jdom '. This is only an problem if you wanted to use it.
Info-type 'org. JDOM. element' is not convertable due to missing converter 'jdom '. This is only an problem if you wanted to use it.
Info-retrieved system configuration file: Java. Io. bytearrayinputstream @ 21e5f0
Info-creator 'pageflow' not loaded due to classnotfoundexception. This is only an problem if you wanted to use it. Cause: beehive/WebLogic creator not available.
Info-converter 'jdom 'Not loaded due to noclassdeffounderror. This is only an problem if you wanted to use it. Cause: ORG/JDOM/Document
Info-found hibernate3 class: org. hibernate. hibernate
Info-type 'org. JDOM. document' is not convertable due to missing converter 'jdom '. This is only an problem if you wanted to use it.
Info-type 'org. JDOM. element' is not convertable due to missing converter 'jdom '. This is only an problem if you wanted to use it.
Info-retrieved system configuration file: Java. Io. bytearrayinputstream @ 618b08
Info-creator 'pageflow' not loaded due to classnotfoundexception. This is only an problem if you wanted to use it. Cause: beehive/WebLogic creator not available.
Info-converter 'jdom 'Not loaded due to noclassdeffounderror. This is only an problem if you wanted to use it. Cause: ORG/JDOM/Document
Info-found hibernate3 class: org. hibernate. hibernate
Info-type 'org. JDOM. document' is not convertable due to missing converter 'jdom '. This is only an problem if you wanted to use it.
Info-type 'org. JDOM. element' is not convertable due to missing converter 'jdom '. This is only an problem if you wanted to use it.
I found a lot of information on the Internet, said less of the JDOM package, plus the following URL of the jdom-1.0.jar package
Http://mirrors.ibiblio.org/pub/mirrors/maven/jdom/jars/jdom-1.0.jar
(Add the corresponding package,
Http://www.findjar.com/jar/jdom/jars/jdom-1.0.jar.html
Http://www.java2s.com/Code/Jar/Spring-Related/Downloadjsfapijar.htm)
the operation still encountered an error, but this time there were fewer errors. Error:
Info-retrieved system configuration file: Java. io. bytearrayinputstream @ adb24
Info-creator 'pageflow' not loaded due to classnotfoundexception. this is only an problem if you wanted to use it. cause: beehive/WebLogic creator not available.
Info-found hibernate3 class: Org. hibernate. hibernate
Info-retrieved system configuration file: Java. io. bytearrayinputstream @ 1f23ca4
Info-creator 'pageflow' not loaded due to classnotfoundexception. this is only an problem if you wanted to use it. cause: beehive/WebLogic creator not available.
Info-found hibernate3 class: Org. hibernate. hibernate
Info-retrieved system configuration file: Java. io. bytearrayinputstream @ 9ced84
Info-creator 'pageflow' not loaded due to classnotfoundexception. this is only an problem if you wanted to use it. cause: beehive/WebLogic creator not available.
Info-found hibernate3 class: Org. hibernate. hibernate
This error is really troublesome. I made a round trip on the internet, and I still couldn't find the cause of the Error. Some people say it's a problem with the xalan package. I did it, but I still can't do it, sorry, I am dead. It took several hours to waste. The last time I tried to change the doctype header file, the problem was solved. You can have a good night's sleep! The following is my correct DWR. xml file:
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype DWR public
"-// Getahead limited // DTD direct Web remoting 1.0 // en"
Http://www.getahead.ltd.uk/dwr/dwr10.dtd>
<DWR>
<Allow>
<! -- Resources not in this war file: Java. util. date -->
<Create creator = "Spring" javascript = "hello">
<Param name = "beanname" value = "hello"/>
</Create>
</Allow>
</DWR>