DWR 2.0 老是报未定义的错!~
tomcat 6.0 +Myeclipse+eclipse 3.2Hello类:
package com.svse.bao;
public class Hello
{
public void hello()
{
System.out.print("hello");
}
}
Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
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_4.xsd">
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
上面的没错吧!
dwr.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "dwr10.dtd" >
<dwr>
<allow>
<create creator="new" javascript="Hello">
<param name="class" value="com.svse.bao.Hello"></param>
</create>
</allow>
</dwr>
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
//要倒的三个js
//
<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>
//要说Hello未定义
<script type="text/javascript">
function hello()
{
//要说Hello未定义,我放了个alert这!~程序到这之后就不跑了!~
Hello.hello();
}
</script>
</head>
<body>
<input type="button" value="test" onclick="hello()">
</body>
</html>
控制台:
2008-10-14 22:23:32 org.apache.catalina.core.ApplicationContext log
严重: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.directwebremoting.dwrp.PollHandler.<clinit>(PollHandler.java:443)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.directwebremoting.impl.ContainerUtil.class$(ContainerUtil.java:97)
at org.directwebremoting.impl.ContainerUtil.setupDefaults(ContainerUtil.java:150)
at org.directwebremoting.impl.ContainerUtil.setupDefaultContainer(ContainerUtil.java:125)
at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:73)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:808)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
搜索更多相关主题的帖子:
DWR 定义
----------------解决方案--------------------------------------------------------
我这有个那时照着文档做的例子
----------------解决方案--------------------------------------------------------
回复 2# guoxhvip 的帖子
谢谢版主!~ ----------------解决方案--------------------------------------------------------
没有加common-logging包。。。。
----------------解决方案--------------------------------------------------------
有可能是dwr的dwr.js或util.js文件有问题 以前我也遇到过类似情况 重新下载了个dwr包 把两个js文件重新放一次就行了
----------------解决方案--------------------------------------------------------