- 浏览: 17978 次
- 性别:
- 来自: 上海
文章分类
最新评论
java 代码
- //============ the file name: D:\workspace\dweb\src\components.xml\components.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <components>
- <component>
- <!--缁勪欢瀛樺湪鑼冨洿锛屽彲浠ユ槸request,session,application-->
- <scope>session</scope>
- <class>Awebwork.ioc.larmRecord</class>
- <enabler>webwork.ioc.AlarmRecordAware</enabler>
- </component>
- </components>
- //============ the file name: D:\workspace\dweb\src\messages_zh_CN.properties\messages_zh_CN.properties
- xname=carlos
- //============ the file name: D:\workspace\dweb\src\test.java\test.java
- public class test {
- public static void main(String[] args) {
- System.out.println("fffffffffff");
- }
- }
- //============ the file name: D:\workspace\dweb\src\validators.xml\validators.xml
- <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
- 1.0//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd">
- <validators>
- <validator name="required"
- class="com.opensymphony.xwork.validator.validators.RequiredFieldValidator" />
- <validator name="requiredstring"
- class="com.opensymphony.xwork.validator.validators.RequiredStringValidator" />
- <validator name="int"
- class="com.opensymphony.xwork.validator.validators.IntRangeFieldValidator" />
- <validator name="date"
- class="com.opensymphony.xwork.validator.validators.DateRangeFieldValidator" />
- <validator name="expression"
- class="com.opensymphony.xwork.validator.validators.ExpressionValidator" />
- <validator name="fieldexpression"
- class="com.opensymphony.xwork.validator.validators.FieldExpressionValidator" />
- <validator name="email"
- class="com.opensymphony.xwork.validator.validators.EmailValidator" />
- <validator name="url"
- class="com.opensymphony.xwork.validator.validators.URLValidator" />
- <validator name="visitor"
- class="com.opensymphony.xwork.validator.validators.VisitorFieldValidator" />
- <validator name="conversion"
- class="com.opensymphony.xwork.validator.validators.ConversionErrorFieldValidator" />
- </validators>
- //============ the file name: D:\workspace\dweb\src\webwork\action\HelloWebWorldAction-helloWebWorld-validation.xml\HelloWebWorldAction-helloWebWorld-validation.xml
- <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
- 1.0//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd">
- <validators>
- <field name="user.username">
- <field-validator type="requiredstring">
- <message>You must enter a value for username.</message>
- </field-validator>
- </field>
- <field name="user.password">
- <!-- WebWork 鏁欑▼ 鏈変换浣曟剰瑙佸拰寤鸿锛岃email to:achqian@hotmail.com锛圡SN锛? 鐗堟潈鎵?鏈夛紝璇峰嬁杞浇鍜岀鏀?-->
- <field-validator type="requiredstring">
- <message>You must enter a value for password.</message>
- </field-validator>
- <field-validator type="fieldexpression">
- <param name="expression">
- user.password == verifyPassword
- </param>
- <message>Passwords don't match.</message>
- </field-validator>
- </field>
- <field name="user.email">
- <field-validator type="email">
- <message>You must enter a valid email.</message>
- </field-validator>
- </field>
- <field name="user.age">
- <field-validator type="int">
- <param name="min">6</param>
- <param name="max">100</param>
- <message>
- Age must be between ${min} and ${max}, current value is
- ${user.age}.
- </message>
- </field-validator>
- </field>
- </validators>
- //============ the file name: D:\workspace\dweb\src\webwork\action\HelloWebWorldAction.java\HelloWebWorldAction.java
- package webwork.action;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import webwork.bean.User;
- import webwork.ioc.AlarmRecord;
- import webwork.ioc.AlarmRecordAware;
- import com.opensymphony.webwork.ServletActionContext;
- import com.opensymphony.webwork.dispatcher.ServletActionRedirectResult;
- import com.opensymphony.webwork.interceptor.SessionAware;
- import com.opensymphony.xwork.Action;
- import com.opensymphony.xwork.ActionContext;
- import com.opensymphony.xwork.ActionSupport;
- import com.opensymphony.xwork.ModelDriven;
- public class HelloWebWorldAction implements Action, SessionAware,
- AlarmRecordAware {
- private int i;
- private Map session;// 定义session变量
- private AlarmRecord ar;
- private File file;
- public List getDays(){
- List list = new ArrayList();
- list.add("111111111111");
- list.add("22222222222");
- list.add("44444444444");
- return list;
- }
- public HelloWebWorldAction() {
- System.out.println("the aciton has init.. ");
- }
- /*
- * (non-Javadoc)
- *
- * @see webwork.ioc.AlarmRecordAware#setAlarmRecord(webwork.ioc.AlarmRecord)
- */
- public void setAlarmRecord(AlarmRecord alarm) {
- // TODO Auto-generated method stub
- this.ar = alarm;
- }
- public void setSession(Map arg0) {
- this.session = arg0;
- }
- private User user = new User();
- public User getUser() {
- return user;
- }
- public void setUser(User user) {
- this.user = user;
- }
- public String execute() throws IOException {
- // hello = "Hello, WebWorld!";
- System.out.println("the execute : " + i++);
- System.out.println("the upload file: " + file);
- // file upload test .
- // 以下为保存文件,视情况修改
- if(null!=file)
- {
- FileOutputStream outputStream = new FileOutputStream("d://" + file.getName());
- FileInputStream fileIn = new FileInputStream(file);
- byte[] buffer = new byte[1024];
- int len;
- while ((len = fileIn.read(buffer)) > 0)
- {
- outputStream.write(buffer, 0, len);
- }
- fileIn.close();
- outputStream.close();
- }
- ActionContext at = ActionContext.getContext();
- HttpServletRequest request = ServletActionContext.getRequest();
- // ar.setAlarmRecordID(this.toString());
- // System.out.println("--------" + ar.getAlarmRecordID());
- //session.put("user", user.toString());
- System.out.println( user );
- // System.out.println("the action has access .. " + user
- // + new Date().toLocaleString());
- return SUCCESS;
- }
- public String tttts() {
- // hello = "Hello, WebWorld!";
- System.out.println("the tttts : " + i++);
- return SUCCESS;
- }
- public String test() {
- // hello = "Hello, WebWorld!";
- System.out.println("the test : " + i++);
- ActionContext at = ActionContext.getContext();
- at.getSession().put("user", user.toString());
- System.out.println("the action has access .. " + user
- + new Date().toLocaleString());
- return SUCCESS;
- }
- @Override
- protected void finalize() throws Throwable {
- // TODO Auto-generated method stub
- super.finalize();
- System.out.println(this + " the action has destoy...");
- }
- /**
- * @return the file
- */
- public File getFile() {
- return file;
- }
- /**
- * @param file the file to set
- */
- public void setFile(File file) {
- this.file = file;
- }
- }
- //============ the file name: D:\workspace\dweb\src\webwork\action\Test.java\Test.java
- package webwork.action;
- public class Test {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- }
- }
- //============ the file name: D:\workspace\dweb\src\webwork\bean\User.java\User.java
- package webwork.bean;
- public class User {
- private String username;
- private String password;
- private String email;
- private int age;
- public User(){
- System.out.println("the user has init..");
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String toString(){
- return "username=" + username + ";password=" + password + ";email="
- + email + ";age=" + age;
- }
- }
- //============ the file name: D:\workspace\dweb\src\webwork\interceptor\MyInterceptor.java\MyInterceptor.java
- package webwork.interceptor;
- import java.util.Calendar;
- import com.opensymphony.xwork.ActionInvocation;
- import com.opensymphony.xwork.interceptor.AroundInterceptor;
- import com.opensymphony.xwork.interceptor.Interceptor;
- public class MyInterceptor extends AroundInterceptor {
- public void init() {
- System.out.println(" <<<<<<<the interceptor >>> " + Calendar.getInstance().getTime().toLocaleString());
- }
- public void destroy() { }
- // public String intercept(ActionInvocation invocation) throws Exception {
- // System.out.println("???????????????????????????");
- // Calendar calendar = Calendar.getInstance();
- // System.out.println(" <<<<<<<the interceptor >>> "
- // + calendar.getTime().toLocaleString());
- // int hour = calendar.get(Calendar.HOUR_OF_DAY);
- // String greeting = (hour < 6) ? "Good evening"
- // : ((hour < 12) ? "Good morning"
- // : ((hour < 18) ? "Good afternoon" : "Good evening"));
- //
- // invocation.getInvocationContext().getSession()
- // .put("greeting", greeting);
- //
- // String result = invocation.invoke();
- //
- // return result;
- // }
- /* (non-Javadoc)
- * @see com.opensymphony.xwork.interceptor.AroundInterceptor#after(com.opensymphony.xwork.ActionInvocation, java.lang.String)
- */
- @Override
- protected void after(ActionInvocation arg0, String arg1) throws Exception {
- // TODO Auto-generated method stub
- System.out.println("the after..*********************");
- }
- /* (non-Javadoc)
- * @see com.opensymphony.xwork.interceptor.AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation)
- */
- @Override
- protected void before(ActionInvocation arg0) throws Exception {
- // TODO Auto-generated method stub
- System.out.println("the before..");
- }
- }
- //============ the file name: D:\workspace\dweb\src\webwork\ioc\AlarmRecord.java\AlarmRecord.java
- package webwork.ioc;
- public class AlarmRecord {
- private String AlarmRecordID;
- public AlarmRecord() {
- System.out.println("the alarmrecord creating..." + this);
- }
- public void setAlarmRecordID(String id) {
- System.out.println("the setAlarmRecordID called ");
- this.AlarmRecordID = id;
- }
- public String getAlarmRecordID() {
- System.out.println("the getAlarmRecordID called ");
- return this.AlarmRecordID;
- }
- }
- //============ the file name: D:\workspace\dweb\src\webwork\ioc\AlarmRecordAware.java\AlarmRecordAware.java
- package webwork.ioc;
- public interface AlarmRecordAware {
- public void setAlarmRecord(AlarmRecord alarm) ;
- }
- //============ the file name: D:\workspace\dweb\src\webwork\WebWorkTestCase.java\WebWorkTestCase.java
- package webwork;
- import java.util.HashMap;
- import java.util.Map;
- import webwork.action.HelloWebWorldAction;
- import com.opensymphony.xwork.Action;
- import com.opensymphony.xwork.ActionContext;
- import com.opensymphony.xwork.ActionProxy;
- import com.opensymphony.xwork.ActionProxyFactory;
- import junit.framework.TestCase;
- public class WebWorkTestCase extends TestCase {
- public void testCreateUserWithProxyFactory() throws Exception {
- System.out.println(Action.SUCCESS);
- Map params = new HashMap();
- params.put("user.username","test");
- params.put("user.email", "test@test.com");
- params.put("user.password", "1234");
- params.put("user.confirm", "1234");
- Map context = new HashMap();
- context.put(ActionContext.PARAMETERS, params);
- ActionProxyFactory factory = ActionProxyFactory.getFactory();
- ActionProxy proxy = factory.createActionProxy("", "helloWebWorld",
- context);
- // proxy.execute();
- HelloWebWorldAction action = (HelloWebWorldAction) proxy.getAction();
- String result = action.execute();
- assertEquals(result, Action.SUCCESS);
- }
- }
- //============ the file name: D:\workspace\dweb\src\xwork.xml\xwork.xml
- <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
- "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
- <xwork>
- <!-- Include webwork defaults (from WebWork JAR). -->
- <include file="webwork-default.xml" />
- <include file="config-browser.xml" />
- <!-- Configuration for the default package. -->
- <package name="default" extends="webwork-default">
- <!-- Default interceptor stack. -->
- <interceptors>
- <interceptor name="greeting"
- class="webwork.interceptor.MyInterceptor" />
- &nb
相关推荐
WebWork 是一个基于Java的轻量级Web应用框架,它为开发者提供了强大的MVC(Model-View-Controller)架构支持,使得开发Web应用程序更加高效和便捷。本文将详细介绍如何使用WebWork来实现一个基础的"HelloWorld"示例...
### WebWork 2.2.7 + Spring + Hibernate 分页查询技术详解 #### 一、项目背景及架构 本项目采用WebWork 2.2.7框架结合Spring和Hibernate技术实现了一个基本的用户数据分页查询功能。主要目标是根据用户输入的...
WebWork是一个基于Java的MVC(Model-View-Controller)框架,它在早期的Web开发中广泛应用,后来发展成为Struts2的一部分。WebWork的核心设计理念是通过动作(Action)来处理用户请求,并将业务逻辑与表示层分离,...
WebWork 是一个由 OpenSymphony 开发的 J2EE Web 框架,专注于组件化和代码重用,采用拉出式MVC模式。在WebWork2.x版本中,它由Xwork和WebWork2两个项目组成。Xwork作为基础,提供Command模式实现,包括前端拦截器、...
webwork是与struts2相似的一种web开发框架,这里这个demo可以让你轻松学习webwork基本的action配置、访问,为了区别可以在本空间中下载基于struts2框架的应用Struts2,加以对比,可以让你一下学习两种web框架。
WebWork 是一个基于Java的开源MVC(Model-View-Controller)框架,它主要用于构建企业级的Web应用程序。WebWork1.4是该框架的一个较早版本,它为开发者提供了强大的功能,包括动作映射、数据绑定、异常处理、国际化...
WebWork 是一个基于 Java 的开源 MVC(Model-View-Controller)框架,它在早期的 Web 应用开发中非常流行,尤其是在 Struts 1 之前。WebWork 提供了强大的动作(Action)处理、类型转换、拦截器(Interceptor)机制...
### Spring+WebWork+iBatis 组合实例详解 #### 一、概述 在Java Web开发领域,Spring、WebWork与iBatis是三个非常重要的框架。本篇将结合具体的配置文件来详细介绍这三个框架是如何协同工作的,以及它们各自在项目...
### Webwork教程知识点详解 #### 一、WebWork框架简介 **WebWork**是一个开源的Java Web...学习并掌握WebWork/Struts2将为开发者提供坚实的技能基础,无论是在实际工作中还是在个人技术成长方面都将带来巨大的收益。
WebWork2.0是一款基于Java的企业级Web应用框架,它为开发者提供了强大的MVC(Model-View-Controller)架构支持,旨在简化Web应用程序的开发流程,提高代码的可维护性和可扩展性。本讲解将围绕WebWork2.0的核心概念、...
包括webwork2.x的 具体使用步骤,见解压后“webwork使用步骤.txt” 和一个实现前后台连通的webwork具体应用的“test” 实例,将test导入eclipse的工作空间,即可正常运行
WebWork是一个基于Java的轻量级MVC(Model-View-Controller)框架,它为构建高性能、可维护的Web应用程序提供了强大的支持。WebWork docs 2 是一套完整的WebWork框架的详细说明文档,包含了开发者在使用WebWork时...
WebWork2是一款基于Java的MVC(Model-View-Controller)框架,用于构建Web应用程序。在Web开发领域,它提供了一种结构化和模块化的开发方式,帮助开发者更高效地组织代码并实现业务逻辑。本指南将深入探讨WebWork2的...
WebWork 是一个开源的、基于Java的Web应用程序框架,它专为构建动态、交互式的Web应用而设计。这个框架的核心理念是模型-视图-控制器(MVC)架构模式,帮助开发者将业务逻辑、用户界面和数据管理分离开来,从而提高...
WebWork是一个基于Java的MVC(Model-View-Controller)框架,它在早期的Web开发中扮演了重要的角色,尤其是在Struts之前或作为其替代品出现。WebWork提供了许多先进的特性,如动作拦截器、类型转换、强大的异常处理...
WebWork 是一个基于Java的MVC(模型-视图-控制器)框架,它在Web应用程序开发中被广泛使用。WebWork 1 和 WebWork 2 都是该框架的不同版本,每个版本都有其特性和改进。 WebWork 1 是早期的版本,提供了基础的MVC...
- 通过日志框架如Log4j进行调试,追踪应用运行过程。 10. **最佳实践**: - 使用ActionSupport基类,它提供了很多默认行为和便利方法。 - 尽量保持Action轻量级,避免在Action中包含过多的业务逻辑。 本中文...