gpt4 book ai didi

java - dwr 服务类未定义

转载 作者:行者123 更新时间:2023-11-30 04:44:29 24 4
gpt4 key购买 nike

我正在使用 dwr 发送和获取一些信息,但出现以下错误。

service(DwrSampleTest) is not defined

当我尝试使用以下行查看文件时:

http://localhost:8080/Servlets-DWR/dwr/index.html

我收到以下异常:访问调试页面被拒绝。

这是我的 dwr.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="Dwrsample">
<param name="class" value="com.dwrsample.servlet.DwrSampleTest"/>
</create>
</allow>
</dwr>

web.xml:

<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>DwrsampleServlet</servlet-name>
<servlet-class>com.dwrsample.servlet.DwrsampleServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

以及我调用该方法的文件:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DWR Sample</title>
<script src='dwr/dwr/engine.js'></script>
<script src='dwr/dwr/util.js'></script>
<script src='dwr/dwr/interface/DwrSampleTest.js'></script>

<script>
function getName() {
DwrSampleTest.getName({callback:setName,async:false});
}
function setName(strName) {
document.getElementById("enterdwr").value = "";
document.getElementById("enterdwr").value = strName;
}
</script>
</head>
<body>
<h1>DWR Sample Test!</h1>

<form method="post" name="dwrsample" id="dwrsample">
<table>
<tr class="lightrow">
<td width="1%">*</td>
<td width="39%">Eenter DWR</td>
<td width="60%"><input name="enterdwr" id="password" type="text" onblur="getName()"/></td>
</tr>
<tr class="lightrow">
<td width="1%">*</td>
<td width="39%">DWR Result</td>
<td width="60%"><input name="resultdwr" id="password" type="text" /></td>
</tr>
</table>
</form>
</body>
</html>

请帮我解决这个问题。

最佳答案

按如下所示更改 dwr.xml 文件中的条目

    <create creator="new" javascript="DwrSampleTest">
<param name="class" value="com.dwrsample.servlet.DwrSampleTest"/>
</create>

Javascript ="DwrSampleTest" must match with the service name that you call in jsp page .

你调用了java类名而不是调用了javascript类名。

并启用调试

<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>

将参数值更改为 true。

关于java - dwr 服务类未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11408039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com