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:
<%@ page language= "java" pageencoding= "UTF-8"%>
<title>my JSP ' first_dwr.jsp ' starting page</title>
<script type= ' text/javascript ' src= ' dwr/interface/service.js ' ></script>
<script type= ' text/javascript ' src= ' js/engine.js ' ></script>
<script type= ' text/javascript ' src= ' js/util.js ' ></script>
<script type= "Text/javascript" >
function Firstdwr () {
Service.sayhello ("Jorwen", Callbackhello);
}
function Callbackhello (data) {
alert (data);
}
</script>
<body>
<input type= "button" name= "button" value= "Test" onclick= "Firstdwr ()" >
</body>
Solution:
To download a dwr.jar on the Internet if 2.0, size 494k, this problem will not occur.
But there is another problem (Eclipse console):
2007-11-19 13:22:52 org.directwebremoting.util.CommonsLoggingOutput Error
Serious: A request has been denied as a potential CSRF attack.
As long as in
In the Web.xml configuration file ...
Configuration of Dwr
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
At this point, the console appears normal. But the JS script will also complain:
Error: Exception was thrown and not caught.
Not to be continued. Co-study.
Then I put the original Dwr.jar a new cover. Okay, everything's fine, it's unbelievable. Finally, I can get started.