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.
xmlns:xsi="http://www.
xsi:schemaLocation="http://java.
http://java.
<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.(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)