- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只允许使用 DWR 2.0.5,因为 DWR 3 尚未发布。我的服务器是 8.0。
我有 2 个 URLS Page1 和 Page 2。Page1 将有一个简单的标签和一个空的文本框。 Page2 什么都没有。首先我将进入 Page1,然后我将在另一个浏览器中进入 Page 2。当我进入 Page2 时,Page1 中的文本框应该填充一条消息“Hello DWR”。我正在尝试使用反向 ajax 来实现这一点。下面是我的代码片段和配置文件。
**DWR.xml**
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.ltd.uk/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="GetSession">
<param name="class" value="com.americanexpress.as.springthread.web.util.GetSession"/>
</create>
<create creator="new" javascript="CallSession">
<param name="class" value="com.americanexpress.as.springthread.web.util.CallSession"/>
</create>
</allow>
</dwr>
**web.xml**
<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_ID" version="3.0" 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_3_0.xsd">
<display-name>SpringThreadWebWAR</display-name>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<description>Direct Web Remoter Servlet</description>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<!-- This should NEVER be present in live -->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!-- Remove this unless you want to use active reverse ajax -->
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- Remove this unless you want to use active reverse ajax -->
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- Keep this to elimintate CSRF attack -->
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<env-entry>
<env-entry-name>SLConfigFile</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>log_servicelocator.xml</env-entry-value>
</env-entry>
</web-app>
**dispatcher-servlet.xml**
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.americanexpress.as.springthread.web.controller" />
<context:component-scan base-package="com.americanexpress.as.springthread.web.processor" />
<context:component-scan base-package="com.americanexpress.as.springthread.web.util" />
<mvc:view-controller path="/" view-name="index" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="fileData" class="com.americanexpress.as.springthread.web.util.FileData" />
<bean id="schedulerTask" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject" ref="fileData" />
<property name="targetMethod" value="createFile" />
</bean>
<bean id="timerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask" ref="schedulerTask" />
<property name="delay" value="600000000" />
<property name="period" value="600000000" />
</bean>
<bean class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref local="timerTask" />
</list>
</property>
</bean>
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="1"></property>
<property name="maxPoolSize" value="10"></property>
<property name="WaitForTasksToCompleteOnShutdown" value="true"></property>
</bean>
<bean id="threadRunner" class="com.americanexpress.as.springthread.web.util.ThreadRunner">
<constructor-arg ref="taskExecutor" />
</bean>
</beans>
**Page1.jsp**
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type='text/javascript' src = '<%=request.getContextPath()%>/dwr/interface/GetSession.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
</head>
<body>
<!-- <input type="button" onclick="getSession();"> -->
<label id="label">Session Id</label>
<input type="text" id="tag">
<script type="text/javascript">
window.onload=function()
{
dwr.engine.setActiveReverseAjax(true); // Initiate reverse ajax polling
addAttributeToScriptSession(); // Make a remote call to the server to add an attribute onto the ScriptSession which will be used in determining what pages receive updates!
}
function addAttributeToScriptSession()
{
alert('vamsi');
GetSession.getSessionValue();
}
function getIt()
{
alert('Maaan');
}
</script>
</body>
</html>
**Page2.jsp**
<%@page import="com.americanexpress.as.springthread.web.util.StatMap"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type='text/javascript' src = '<%=request.getContextPath()%>/dwr/interface/CallSession.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
</head>
<body>
<!-- <input type="button" onclick="getSession();"> -->
<script type="text/javascript">
window.onload=function()
{
dwr.engine.setActiveReverseAjax(true); // Initiate reverse ajax polling
callSession(); // Make a remote call to the server to add an attribute onto the ScriptSession which will be used in determining what pages receive updates!
}
function callSession()
{
alert('krishna');
CallSession.callSession();
}
</script>
</body>
</html>
**CallSession.java**
package com.americanexpress.as.springthread.web.util;
import org.directwebremoting.ScriptSession;
import org.directwebremoting.ServerContext;
import org.directwebremoting.beehive.PageFlowCreator;
import org.directwebremoting.proxy.dwr.Util;
public class CallSession {
public void callSession() throws ClassNotFoundException{
ScriptSession sessionId = (ScriptSession)StatMap.statMap.get("sessionId");
System.out.println("Session id in Page2 "+sessionId);
/*Browser.withPage(sessionId.getPage(), new Runnable(){
public void run() {
Util.setValue("tag", "Hello World");
}
});*/
Util u = new Util(sessionId);
System.out.println("The value of u is "+u);
u.setValue("tag","Hello World");
}
}
**GetSession.java**
package com.americanexpress.as.springthread.web.util;
import org.directwebremoting.ScriptSession;
import org.directwebremoting.WebContextFactory;
public class GetSession {
public void getSessionValue(){
ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
System.out.println("************************"+scriptSession.getId()+"************************");
StatMap.statMap.put("sessionId",scriptSession);
}
}
Now after I execute this, I'm always getting the below exception
**Exception**
[2/12/14 6:31:50:775 MST] 0000001e PollHandler E org.directwebremoting.dwrp.PollHandler checkNotCsrfAttack A request has been denied as a potential CSRF atack.
[2/12/14 6:31:50:781 MST] 0000001e ExceptionHand W org.directwebremoting.util.CommonsLoggingOutput warn Unhandled Exception
java.lang.SecurityException: Session Error
at org.directwebremoting.dwrp.PollHandler.checkNotCsrfAttack(PollHandler.java:252)
at org.directwebremoting.dwrp.PollHandler.handle(PollHandler.java:99)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3704)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
[2/12/14 6:31:50:791 MST] 0000001e webapp E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[dwr-invoker]: com.ibm.wswebcontainer.webapp.WebAppErrorReport: Error. Details logged to the console
at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:624)
at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:642)
at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1236)
at org.directwebremoting.servlet.ExceptionHandler.handle(ExceptionHandler.java:59)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:112)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3704)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
Kindly let me know if any configuration or any implementation is wrong a
Regards,
Vamsi
最佳答案
在您的 web.xml
你有这行代码
<!-- Keep this to elimintate CSRF attack -->
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
E org.directwebremoting.dwrp.PollHandler checkNotCsrfAttack
A request has been denied as a potential CSRF atack.
web.xml
中对...
关于dwr - DWR 2.0.5 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21780720/
DWR 是一个死的项目吗?它似乎没有在积极开发中。最新的 3.0 版本似乎停滞不前。我特别想知道是否会有 DWR 1.x 或 2.x 的维护版本,或者是否会发布 3.0。 顺便提一句。我在其中一个 D
我是 DWR 的初学者。根据 (http://directwebremoting.org/dwr-demo/simple/text.html) 中的教程,我将 dwr 脚本放置在我的 html 文件中
我只允许使用 DWR 2.0.5,因为 DWR 3 尚未发布。我的服务器是 8.0。 我有 2 个 URLS Page1 和 Page 2。Page1 将有一个简单的标签和一个空的文本框。 Page2
我目前使用 DWR 2 进行开发,但我现在想尝试 DWR 3。我不明白如何用 DWR 3 制作 cometd 。我在 Google 上搜索了很多次,但没有找到任何好的例子。有人可以帮助我吗? 最佳答案
环境 Websphere 8.5.5.11 JDK 1.8 DWR SpringMVC Oracle DBMS 我们最近升级了我们的项目,并进行了更新 spring.jar, spring-web.j
我正在使用 DWR,这是我相当新的...我使用 ajax 向页面提交评论,我收到请求查看提交评论时是否可以显示 tmestamp: 简而言之,该 bean 有一个称为可审计的变量...在到达数据库之前
是否可以上传文件,然后在收到响应时下载文件, 我的意思是在一个请求中我将上传一个文件并在一个操作中下载该文件? 最佳答案 也许这个演示代码会对您有所帮助: http://directwebremoti
当我登录到我的 webapp dwr 时开始执行,然后生成此错误日志: 18-11-2009 12:09:13 [http-8080-Processor24] ERROR org.directwebr
我是 DWR World 的新手,在理解应用程序的正确行为方面遇到一些问题。 我有这样的情况: 文件 dwr.xml 在我的 html 页面
我从网站上复制了示例,但它不起作用,谁能告诉我原因是什么。我在 tomcat 的控制台日志中没有收到任何异常或错误。 下面是我的文件dwrtest.jsp DIRECT
我正在开发一个 Java Web 应用程序,它在很多地方使用了 DWR。我添加了一个新的 DWR 组件,该组件不得将任何错误传播回最终用户。目前,如果出现服务器端错误,则会在弹出窗口中显示给用户,我想
我希望 DWR 透明地批处理在处理同一事件过程中完成的所有远程调用。 原因是在 Javascript 中处理一个事件必须只需要很短的时间,并且在同一时间内不能发生任何其他事情。因此,如果我要进行许多调
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 9 年前。 Improve this qu
大家好,我正在使用 dwr 处理 java-servlet 中的 ajax 调用, 这是我的dwr.xml,
我已经使用 DWR 和转换器有一段时间了,我真的很想将我的 Java 类映射到 JavaScript 类。使用 DWR 转换器,我可以选择指出给定 Java 类的 JS 构造函数的名称。到目前为止一切
我正在使用 dwr 发送和获取一些信息,但出现以下错误。 service(DwrSampleTest) is not defined 当我尝试使用以下行查看文件时: http://localhost:
我试图在我的 DWR 方法调用中捕获并处理 NullPointerException 的返回: CompaniesByCountyFactory.getElementCompanies(command
我想申请一个项目类别的集合(具体反射(reflect))。但是关于类型删除似乎是不可能的,而且关于我在堆栈上阅读过的一些主题。有一些解决方法(here),但我很好奇是否有人知道它是如何完成的,例如 D
我正在尝试编写一个带有直接 Web 远程处理的示例程序。浏览网站http://directwebremoting.org/有一些基本的问题。请帮助我 试用什么程序http://directwebrem
我有一个关联数组。我希望能够使用关联数组键作为选项值,使用数组键作为选项元素的文本,将选项添加到下拉列表中。 var associativeArray = new Array(); associa
我是一名优秀的程序员,十分优秀!