Chinaunix首页 | 论坛 | 博客
  • 博客访问: 110195
  • 博文数量: 19
  • 博客积分: 600
  • 博客等级: 上士
  • 技术积分: 230
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-12 04:04
文章分类

全部博文(19)

文章存档

2014年(4)

2009年(2)

2008年(13)

我的朋友

分类: Java

2008-01-19 04:01:33

web.xml 配置
 
 

<?xml version="1.0" encoding="UTF-8"?>

<!--
    Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
    Use is subject to license terms.
-->

<web-app version="2.4" xmlns=""
    xmlns:xsi=""
    xsi:schemaLocation=" /web-app_2_4.xsd">
    <display-name>hello</display-name>
    <distributable />


    <filter>
        <filter-name>struts-cleanup</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>struts</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

 

struts.xml 配置

 

 

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "">

<struts>
    <constant name="struts.devMode" value="false" />
    <constant name="struts.action.extension" value="html" />
    <package name="eicp" namespace="/" extends="struts-default">

        <action name="index" class="HelloWorld">
            <result name="sucess">/resource/index.jsp</result>
        </action>

    </package>

</struts>

 

HelloWorld 类

 

public class HelloWorld {
    
    private static final String Message="Hello World";
    
    private static final String SUCCESS = "sucess";
    
    

    public String getMessage() {
        return Message;
    }
    
    public String execute ( ) {    
            
            return SUCCESS;
    
        }
    /**
     * @param args
     */

    public static void main(String[] args) {
        // TODO Auto-generated method stub


    }

}

 

index.jsp 使用的视图文件

 

<%@taglib prefix="s" uri="/struts-tags" %>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<s:property value="getMessage()"/>

<a href="">index</a>
<br/>

</body>
</html>

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