struts2.0學(xué)習(xí)筆記-20070511-1

          新建類HelloWorld.java:

          package myexample;

          import com.opensymphony.xwork2.ActionSupport;

          /**
           * 
          @author deepbluesea
           * myexample
           *
           
          */

          public class HelloWorld extends ActionSupport{
              
              
          private String message;
              
              
          public static final String MYMESSAGE="HelloWorld.message";

              
          public String getMessage() {
                  
          return message;
              }


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

              
              
          public String execute() throws Exception{
                  setMessage(getText(MYMESSAGE));
                  
          return SUCCESS;
              }

              

          }

          建jsp頁面HelloWorld.jsp
          <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
              pageEncoding
          ="ISO-8859-1"%>
          <%@taglib uri="/struts-tags" prefix="s" %>
          <!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; charset=ISO-8859-1">
          <title>
          <s:text name="HelloWorld.message"></s:text>
          </title>
          </head>
          <body>
          <s:property value="message"/>

          </body>
          </html>


          寫配置文件myexample.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE struts PUBLIC
                  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                  "http://struts.apache.org/dtds/struts-2.0.dtd"
          >
          <struts>

             
          <package name="myexample" namespace="/myexample" extends="struts-default">
                
          <action name="HelloWorld" class="myexample.HelloWorld">
                  
          <result>/myexample/HelloWorld.jsp</result>
                
          </action>
             
             
          </package>
          </struts>

          把myexample.xml包含到struts.xml中:
          <?xml version="1.0" encoding="UTF-8" ?>
          <!DOCTYPE struts PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
              "http://struts.apache.org/dtds/struts-2.0.dtd"
          >

          <struts>

              
          <constant name="struts.enable.DynamicMethodInvocation" value="false" />
              
          <constant name="struts.devMode" value="true" />

              
          <include file="example.xml"/>
              
              
          <include file="myexample.xml"></include>

              
          <!-- Add packages here -->

          </struts>


            

          posted on 2007-05-11 11:16 deepbluesea 閱讀(274) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2007年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導(dǎo)航

          統(tǒng)計(jì)

          公告

          MSN:zzlljj8833@hotmail.com lava:5832911

          常用鏈接

          留言簿(1)

          隨筆分類(9)

          隨筆檔案(18)

          文章分類(1)

          文章檔案(1)

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 河源市| 航空| 伊川县| 农安县| 老河口市| 怀远县| 石家庄市| 汾西县| 荣昌县| 甘南县| 普安县| 留坝县| 大安市| 富宁县| 朝阳区| 霸州市| 报价| 连江县| 洪湖市| 洪雅县| 辽宁省| 淮南市| 三江| 松阳县| 繁昌县| 台中县| 富蕴县| 德昌县| 宁远县| 冀州市| 措美县| 龙南县| 关岭| 婺源县| 沙田区| 兴业县| 苏尼特右旗| 大庆市| 永昌县| 乾安县| 高密市|