struts2中 用dwr实现AJAX的功能,DWR的调试画面怎么出不来,哪里有问题,帮忙看一下,代码贴出己经。
Action
package com.dwr;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private static final long serialVersionUID = 1L;
private String name;
public HelloWorld(){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String sayHello(String name){
return "Hello,"+name;
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="org" extends="struts-default" namespace="/">
<default-action-ref name="def"></default-action-ref>
</package>
</struts>
dwr.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN"
"http://directwebremoting.org/dwr/dwr30.dtd">
<dwr>
<allow>
<creat creator="new" javascript="Hello">
<param name="class" value="com.dwr.HelloWorld"></param>
</creat>
</allow>
</dwr>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<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>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>DWR's HelloWorld</title>
<script type='text/javascript' src='/struts2dwr/dwr/engine.js'></script>
<script type='text/javascript'
src='/struts2dwr/dwr/interface/Hello.js'></script>
<script type='text/javascript' src='/struts2dwr/dwr/util.js'></script>
<script type="text/javascript">
function hello(){
var user = $('user').value;
alert(user);
Hello.sayHello(user,callback);
}
function callback(msg