能正常启动服务器,在jsp页面上使用配置的dwr时,控制台输出:2011-06-03 23:28:38,906 ERROR org.directwebremoting.impl.DefaultCreatorManager:(DefaultCreatorManager.java:183)
- Class not found: 'tJianSerivce'现在我贴出相关代码如下
web.xml:
<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>org.directwebremoting.spring.DwrSpringServlet</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>
<init-param>
<param-name>allowScriptTagRemoting</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
default-autowire="byName"> <aop:aspectj-autoproxy/>
<context:component-scan base-package="cn.eam.product"/>
<dwr:annotation-config/> <!--扫描需要转换的Java对象-->
<dwr:annotation-scan scanRemoteProxy="false" base-package="en.eam.product"/> <dwr:configuration/> <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="product"/>
</bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean> <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
相关的bean都使用了注解。dwr.xml:
<create creator="spring" javascript="tJianSerivce">
<param name="beanName" value="tJianSerivce"/>
</create>jsp页面部分代码:<script type='text/javascript' src='/product/dwr/util.js'></script>
<script type='text/javascript' src='/product/dwr/engine.js'></script>
<script type='text/javascript' src='/product/dwr/interface/tJianSerivce.js'></script>
<script type="text/javascript">
function change_seedCode(){
var seedCodeList = document.getElementById("seedCode").value;
if(domainId != null){
tJianSerivce.getSeedNameByCode(seedCodeList,callBack_seedName);
tJianSerivce.getSeedNameByType(seedCodeList,callBack_seedType);
}
}
function callBack_seedName(seedCodeList){
${"codeName"}.value = "";
for(var i = 0; i < seedCodeList.length; i++){
var value = seedCodeList[i].toString();
var text = new Text(value);
try{
document.getElementById("seedName").value = text;
}catch(e){
Alert.showFrame(e.toJSON());
}
}
}请好心人根据小弟所提供的信息,诊断一下,呵呵,谢谢。
- Class not found: 'tJianSerivce'现在我贴出相关代码如下
web.xml:
<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>org.directwebremoting.spring.DwrSpringServlet</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>
<init-param>
<param-name>allowScriptTagRemoting</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
default-autowire="byName"> <aop:aspectj-autoproxy/>
<context:component-scan base-package="cn.eam.product"/>
<dwr:annotation-config/> <!--扫描需要转换的Java对象-->
<dwr:annotation-scan scanRemoteProxy="false" base-package="en.eam.product"/> <dwr:configuration/> <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="product"/>
</bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean> <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
相关的bean都使用了注解。dwr.xml:
<create creator="spring" javascript="tJianSerivce">
<param name="beanName" value="tJianSerivce"/>
</create>jsp页面部分代码:<script type='text/javascript' src='/product/dwr/util.js'></script>
<script type='text/javascript' src='/product/dwr/engine.js'></script>
<script type='text/javascript' src='/product/dwr/interface/tJianSerivce.js'></script>
<script type="text/javascript">
function change_seedCode(){
var seedCodeList = document.getElementById("seedCode").value;
if(domainId != null){
tJianSerivce.getSeedNameByCode(seedCodeList,callBack_seedName);
tJianSerivce.getSeedNameByType(seedCodeList,callBack_seedType);
}
}
function callBack_seedName(seedCodeList){
${"codeName"}.value = "";
for(var i = 0; i < seedCodeList.length; i++){
var value = seedCodeList[i].toString();
var text = new Text(value);
try{
document.getElementById("seedName").value = text;
}catch(e){
Alert.showFrame(e.toJSON());
}
}
}请好心人根据小弟所提供的信息,诊断一下,呵呵,谢谢。
<create creator="spring" javascript="tJianSerivce">
<param name="beanName" value="tJianSerivce"/>
</create>他呢?注解 和xml不是一个servlet-class用@DataTransferObject注解 就可以解析bean类http://directwebremoting.org/dwr/javadoc/org/directwebremoting/annotations/DataTransferObject.html
ExportIj.execExport(loginId,rh_report_id,bbq,bbh,standard,function(jdata){
document.all.waitDivForm.style.visibility="hidden";
alert(jdata);
//window.open("downloadIJ1.jsp?filename="+jdata);
top.window.close();
});这是我原来用的时候的一个例子 前面是参数 必须和后台的方法对应起来 最后一个jdata是返回的结果
好像javascript里的名字和后台的方法名字不能一样 不然找不着(大概是这样,记得不是很清楚了 好久之前用的)
dwr中的配置
<create javascript="IJLogicService" creator="new">
<param name="class" value="com.thtf.oem.boc.IJLogicService"></param>
</create>
web.xml中的配置
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<servlet-class>uk.ltd.getahead.dwr.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>
用的时候就是你javascript里面的那个名字。方法名就行了 别的dwr都做好了