⒈下载webwork2.2.4.zip文件.
⒉新建工程 webwork
⒊拷贝webwork-2.2.4/webwork-2.2.4.jar , webwork-2.2.4/lib/default/commons-logging.jar , freemarker.jar , javamail.jar , ognl.jar , oscore.jar , rife-contiunations.jar , xwork.jar包到webwork/WEB-INF/lib文件夹下
⒋拷贝webwork-2.2.4/src/java/webwork-default.xml到webwork/src文件夹下;
拷贝webwork-2.2.4/src/java/META-INF/taglib.tld到webwork/WEB-INF文件夹下.最好改名为webwork.tld
⒌xwork.xml位于webwork/src文件夹下,有如下的配置
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
- <xwork>
- <include file="webwork-default.xml"/>
- <package name="default" extends="webwork-default">
- <action name="hello" class="com.sourceware.test.HelloWorldAction">
- <result name="success" type="dispatcher">
- <param name="location">/helloworld.jsp</param>
- </result>
- <interceptor-ref name="params"/>
- </action>
- </package>
- </xwork>
⒍webwork.properties位于webwork/src文件夹下,有如下的配置
- # extension for actions
- webwork.action.extension=action
- webwork.continuations.package = action
- # spring integration
- #webwork.objectFactory=spring
- #webwork.objectFactory.spring.autoWire=type
- ### Configuration reloading
- # This will cause the configuration to reload xwork.xml when it is changed
- webwork.configuration.xml.reload=true
- ### Load custom default resource bundles
- webwork.custom.i18n.resources=default
- ### character encoding
- webwork.i18n.encoding=UTF-8
⒎web.xml位于webwork/WEB-INF文件夹下,有如下的配置
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <filter>
- <filter-name>webwork</filter-name>
- <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>webwork</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
- <jsp-config>
- <taglib>
- <taglib-uri>webwork</taglib-uri>
- <taglib-location>/WEB-INF/webwork.tld</taglib-location>
- </taglib>
- </jsp-config>
- </web-app>
⒏ JAVA类 HelloWorldAction
- package com.sourceware.test;
- import com.opensymphony.xwork.ActionSupport;
- public class HelloWorldAction extends ActionSupport {
- private String username;
- private String welcomeMessage;
- public String execute() throws Exception {
- welcomeMessage = username +",Welcome!";
- return SUCCESS;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getWelcomeMessage() {
- return welcomeMessage;
- }
- }
⒐helloworld.jsp 代码
- <%@ page language="java" pageEncoding="UTF-8"%>
- <%@ taglib prefix = "ww" uri = "/webwork" %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>welcomeResult</title>
- </head>
- <body>
- <ww:property value = "%{welcomeMessage}"/>
- </body>
- </html>
⒑welcome.jsp 代码
- <%@ page language="java" pageEncoding="UTF-8"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Welcome</title>
- </head>
- <body>
- <form name = "register" action = "helloworld.action" method = "POST">
- Name:<input name = "username" >Please input your name.<b><input name="submit" type="submit" value="submit">
- </b></form>
- </body>
- </html>
5111

被折叠的 条评论
为什么被折叠?



