public class PublishAction extends ActionSupport {
private String msg;
/**
* @return the msg
*/
public String getMsg() {
return msg;
}
/**
* @param msg the msg to set
*/
public void setMsg(String msg) {
this.msg = msg;
}
public String showMsg(){
HttpServletResponse response= ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf8");
String page = ServerContextFactory.get().getContextPath() + "/message.jsp";
Browser.withPage(page, new Runnable() {
public void run() {
ScriptSessions.addScript("showMsg('" + msg + "')");
}
});
try {
response.getWriter().print(msg);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(msg);
return SUCCESS;
}
}
<?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="struts" extends="struts-default" namespace="/">
<action name="publishAction" class="com.acca.action.PublishAction" method="showMsg">
<result>message.jsp</result>
</action>
</package>
</struts>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!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;">
<title>Insert title here</title>
<style type="text/css">
ul,li{margin:0;padding:0}
#scrollDiv{ overflow:auto}
.scrollText{width:300px;height:25px;min-height:25px;line-height:25px;border:#ccc 0px solid; float:right;overflow:hidden}
.scrollText li{height:25px;padding-left:10px;}
.up{ margin-left:310px; width:50px; height:50px; background:#F90}
.down{ margin:0 0 0 310px; zoom:1; width:50px; height:50px; background:#960}
</style>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function() {
dwr.engine.setActiveReverseAjax(true);
});
function showMsg(msg) {
alert(msg);
}
</script>
</head>
<body>
<div id="scrollDiv">
<div class="scrollText">
<ul id="messageList">
</ul>
</div>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!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;">
<title>Insert title here</title>
</head>
<body>
<form action="publishAction.action" method="post">
<input type="text" name="msg">
<input type="submit" value="send">
</form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<welcome-file-list>
<welcome-file>send.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.directwebremoting.servlet.DwrListener</listener-class>
</listener>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<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>
<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>
<!-- By default DWR creates application scope objects when they are first
used. This creates them when the app-server is started -->
<init-param>
<param-name>initApplicationScopeCreatorsAtStartup</param-name>
<param-value>true</param-value>
</init-param>
<!-- WARNING: allowing JSON-RPC connections bypasses much of the security
protection that DWR gives you. Take this out if security is important -->
<init-param>
<param-name>jsonRpcEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- WARNING: allowing JSONP connections bypasses much of the security
protection that DWR gives you. Take this out if security is important -->
<init-param>
<param-name>jsonpEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- data: URLs are good for small images, but are slower, and could OOM for
larger images. Leave this out (or keep 'false') for anything but small images -->
<init-param>
<param-name>preferDataUrlSchema</param-name>
<param-value>false</param-value>
</init-param>
<!-- This enables full streaming mode. It's probably better to leave this
out if you are running across the Internet -->
<init-param>
<param-name>maxWaitAfterWrite</param-name>
<param-value>-1</param-value>
</init-param>
<!--
For more information on these parameters, see:
- http://getahead.org/dwr/server/servlet
- http://getahead.org/dwr/reverse-ajax/configuration
-->
<load-on-startup>1</load-on-startup>
</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>
</web-app>
分享到:
相关推荐
整合spring3 + struts2 + mybatis3 + tiles + dwr3 这几个流行的框架。 spring3,struts2,dwr3都是用的注解,tiles与mybatis是采用的xml配置。
在学习jpa时候做的一个struts2+spring+jpa整合的完整例子 包含分页,一个简单的 资产入库系统 并实现了登陆等。
Struts2+Spring+Hibernate集成+Dwr做Ajax 制作的树形菜单 代码层次结构清晰 一看就懂
网上看到一些例子,对于一个简单的三级联动,都加上什么Struts, Hibernate诸如此类的框架。这个Ajax联动殊不知和这些框架有什么关系,一个小Demo干嘛整得那么大。 今天我做了一个dwr+jsp做的例子。 web.xml: 代码...
2.本程序部分实现AJAX功能,采用DWR框架。 3.程序运行环境为MYECLIPSE 5.0 + TOMACT 5.5 + ORACLE 9i 4.配置说明:将lib目录下的commons-pool-1.2.jar,commons-dbcp-1.2.jar,ojdbc14.jar复制到TOMACT目录下的...
<br>实现原理 基于不重新发明轮子的原则,Struts 2并没有开发新的AJAX框架,而是使用时下Java EE平台中比较流行的AJAX框架——Dojo和DWR。 <br>最近在Musachy Barroso等同志的无私奉献下,开发了Struts 2...
分享:Flex4+Struts2+Spring3+Blazeds 百度空间_应用平台 Flex中嵌入Google地图 - 菩提树 - ITeye技术网站 分享:Flex builder3执行Debug需要安装的Flash Player Debugger环境 百度空间_应用平台 flex4 的DataGrid...
Struts 2并没有开发新的AJAX框架,而是使用时下Java EE平台中比较流行的AJAX框架——Dojo和DWR。 最近在Musachy Barroso等同志的无私奉献下,开发了Struts 2的JSON插件(Plugin),极大地方便了我们输出JSON结果...
34 4.2.4 使用Spring配置DWR 35 4.3 DWR与JSF 36 4.3.1 JSF Creator 36 4.3.2 Servlet Filter 36 4.4 DWR与Struts 37 4.4.1 Struts creator 37 4.4.2 开始顺序 37 4.5 DWR与...
三个ajax实现简单实现 包括dwr struts2 和 struts2、jQuery、json结合。及一个shh jquery json输入提示内容功能例子。
里面是用ssh整合做的一个简单的省市级联的例子,struts用的是1.3版本的 另外dwr实现了同样的功能
本系统是基于J2EE规范的B/S模式的OA系统,主要使用以下技术: Struts + Tomcat + hibernate + MySql技术。...利用OsWorkFlow工作流引擎较简单实现了项目中公文流转模块的一些功能 具有详细资料,只是是06年的项目
本章我们将会开发基于Struts2框架的Hello World.我们的Hello World程序是你开发基于Struts2框架程序的第一步.这里我们会提供循序渐进的教程来开发基于Struts2框架的Hello World程序. 教程包含基本的步骤像创建目录...
主要应用spring2.5,struts1.2,hibrenate3.2,ajax(dwr),Ext简单的模块,用户,角色之间的关系设置添加,管理。数据库SqlServer2005。附加数据,工程导入Eclipse,就可见效果,直接部署Tomcat6也可以
6.3 将Spring与Struts 1.x集成 220 6.3.1 问题 220 6.3.2 解决方案 220 6.3.3 工作原理 220 6.4 将Spring与JSF集成 226 6.4.1 问题 226 6.4.2 解决方案 226 6.4.3 工作原理 227 6.5 将Spring与DWR...
6.3 将Spring与Struts 1.x集成 220 6.3.1 问题 220 6.3.2 解决方案 220 6.3.3 工作原理 220 6.4 将Spring与JSF集成 226 6.4.1 问题 226 6.4.2 解决方案 226 6.4.3 工作原理 227 6.5 将Spring与DWR...