Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29959905
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: Java

2008-03-17 11:37:49

建立WEB

lib下的以下*.jar文件拷WEB目之中。
? struts2-core.jar
? xwork.jar
? ognl.jar
? freemarker.jar
? commons-logging.jar

 

编辑web.xml文件,在文件之中配置Struts2

web.xml

 xmlns:xsi=""
 xsi:schemaLocation="
 /web-app_2_4.xsd">
 
  struts2
  
   org.apache.struts2.dispatcher.FilterDispatcher
  

 

 
  struts2
  /*
 


建立新的Action,所有的Action承自ActionSupport

HelloAction.java
package org.lxh.struts2;

import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport {
 private static final String MESSAGE = "hello.msg";

 private String message;

 @Override
 public String execute() throws Exception {
  this.setMessage(super.getText(MESSAGE));
  return ActionSupport.SUCCESS;
 }

 public String getMessage() {
  return message;
 }

 public void setMessage(String message) {
  this.message = message;
 }
}

新建struts.xml文件

struts.xml

        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "">

   extends="struts-default">
  
   /hello.jsp
  

 

新建package.properties文件

package.properties
hello.msg = HELLO WORLD!!!

建立hello.jsp

hello.jsp
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

 
    My JSP 'hello.jsp' starting page
 
 
 
   


 

注意:
1
 如果用的是Tomcat5.0.28.xalan下的xercesImpl.jarxml-apis.jarTomcat\common\endorsed下的两个jar文件。
2
 需要将xalan下的xalan.jarserializer.jarTomcat\common\lib

阅读(1591) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-05-04 13:51:25

DDDDDD

chinaunix网友2008-05-04 13:49:51

hello world111

chinaunix网友2008-05-04 13:49:18

o