ssh与dwr整合

chenwqi0120 2009-06-25 08:54:21
我使用struts2/spring2.0/hibernate3.1整合一个web项目(test),一切正常。现在我想在原有的基础上整合dwr。

///////web.xml////////////
<context-param>
<param-name>contextConfigLocaltion</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>dwr</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</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

//////////////////////////////////////////////////////
运行 http://localhost:8080/test/dwr/ (正常)

运行 http://localhost:8080/test/index.jsp页面则报错,错误如下:
<s:form action="LoginAction">
<s:textfield id="aname" name="admin.adminname" label="用户名"></s:textfield>
<s:password id="apassword" name="admin.adminpassword" label="密码"></s:password>
</s:form>
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.index_jsp._jspx_meth_s_005fform_005f0(index_jsp.java:168)
org.apache.jsp.index_jsp._jspService(index_jsp.java:134)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

///////////////////////////////////////////////
把web.xml中的struts中的配置路径从 ”*.action“ 改写成 ”/*“
情况与上面反过来了
运行 http://localhost:8080/test/index.jsp/ (正常)

运行 http://localhost:8080/test/dwr/ 错误如下:
There is no Action mapped for action name dwr/.
...全文
226 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiao900424 2010-03-13
  • 打赏
  • 举报
回复
在web.xml中 把Struts2.0 的配置
改为如下:

filter-name>struts2 </filter-name>
<url-pattern>/* </url-pattern>

就行了,但是dwr却又会出错滴!

呵呵
chwplay 2009-11-23
  • 打赏
  • 举报
回复
我今天也是,遇到他说,spring中没返现bean,但是找了,还是没找到解决方案,Ajax还得多多学习哦
wang1986614 2009-06-28
  • 打赏
  • 举报
回复
dwr框架的包,还有web.xml的配置,页面上还要引用地址,然后就是Javascript和Java代码了,看看那里出问题了
robyjeffding 2009-06-26
  • 打赏
  • 举报
回复
顶一下!
chenwqi0120 2009-06-26
  • 打赏
  • 举报
回复
、////////////////////dwr的配置////////////////////////////
<?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="spring" javascript="JAdmin">
<param name="beanName" value="AdminBiz" />
<include method="login" />
</create>
</allow>


</dwr>


/////////////////////////页面代码///////////////////////////////
<html>
<head>

<title>My JSP 'index.jsp' starting page</title>

<script type='text/javascript' src='/test/dwr/interface/JAdmin.js'></script>
<script type='text/javascript' src='/test/dwr/engine.js'></script>
<script type='text/javascript' src='/test/dwr/util.js'></script>

<script type="text/javascript">
function chou()
{
var temp1=document.getElementById("login1");
var temp2=document.getElementById("login2");
temp2.style.display="none";
temp1.style.display="block";
}
function chop()
{
var temp1=document.getElementById("login1");
var temp2=document.getElementById("login2");
temp1.style.display="none";
temp2.style.display="block";
}

function init()
{
var temp2=document.getElementById("login2");
temp2.style.display="none";
}

function sub()
{
alert("aaaaaaaa");
document.forms[0].onsubmit();
}

</script>
</head>

<body style="text-align: center; background-color: #7aa1e6;" onload="init()">
<%-- 登录图片 --%>
<div>
<img src="/test/images/login.jpg">
</div>
<%-- 登录表单 --%>
<div style="margin-top: -260px;margin-left: -40px;">
<s:form action="LoginAction">
<s:textfield id="aname" name="admin.adminname" label="用户名"></s:textfield>
<s:password id="apassword" name="admin.adminpassword" label="密 码"></s:password>
</s:form>
</div>
<%-- 按钮 --%>
<div style="margin-top: -75px;margin-left: 200px;">
<img id="login1" SRC="/test/images/login1.png" width="50" height="50" onmouseover="chop()">
<img id="login2" SRC="/test/images/login2.png" width="50" height="50" onmouseout="chou()" onclick="sub()">
</div>
</body>
</html>
zidasine 2009-06-26
  • 打赏
  • 举报
回复
将dwr 的配置与struts2的配置换下位置看看
zm_hs 2009-06-26
  • 打赏
  • 举报
回复
看你页面上都没有使用DWR啊!
cwmwss 2009-06-26
  • 打赏
  • 举报
回复
我是不用struts了,DWR调spring的方法。。。
shuai45 2009-06-25
  • 打赏
  • 举报
回复
http://localhost:8080/test/dwr/ (正常)

只能说明你的dwr配置没有问题。你最好你把dwr的配置和页面如何应用和使用
贴一下代码

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧