首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts2.1 标签详细说明(二)

2012-10-17 
Struts2.1 标签详细说明(2)!--?最简单的选项卡,两个选项卡加载都是本页面?-- ????????????hr?color ?

Struts2.1 标签详细说明(2)

    <!--?最简单的选项卡,两个选项卡加载都是本页面?--> ????????????<hr?color=
      <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "struts-2.1.7.dtd" ><struts><constant name="struts.custom.i18n.resources" value="struts2"></constant><constant name="struts.configuration.xml.reload" value="true"></constant><package name="package1" namespace="/com/rao" extends="struts-default"><action name="tagsAction1" alt="Struts2.1 标签详细说明(二)">
        package com.rao.action;import com.opensymphony.xwork2.ActionSupport;public class TagsAction1 extends ActionSupport {private String userName;public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}@Overridepublic String execute() throws Exception {return SUCCESS;}}

        ?

        ?

        GlobalNativeAction.java

          package com.rao.action;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;/** * 演示的是在Action 中获取国际化资源文件中的内容 * @author Administrator * */public class GlobalNativeAction extends ActionSupport {@Overridepublic String execute() throws Exception {//不带有占位符的获取方法//ActionContext.getContext().put("message", this.getText("welcome"));//带有占位符的获取方法ActionContext.getContext().put("message", this.getText("welcome",new String[]{"raozhiyong","study"}));return "message";}}

          ?

          ?

          struts2_zh_CN.properties

          ?

          ?

          welcome?? ?? 全局范围:{0},这是一个中文的国际化资源文件,欢迎你的使用{1}!!!

          ?

          GlobalNativeAction_zh_CN.properties

          ?

          ?

          welcome?? ?? Action范围:{0},这是一个中文的国际化资源文件,欢迎你的使用{1}!!!

          ?

          package_zh_CN.properties

          ?

          ?

          welcome?? ?? package范围:{0},这是一个中文的国际化资源文件,欢迎你的使用{1}!!!

          ?

          Sex.java

          ?

          ?

            package com.rao.bean;public class Sex {private int id;private String name;public Sex(int id, String name) {super();this.id = id;this.name = name;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}}

            ?

            ?

            UserBean.java

            ?

              package com.rao.bean;import java.io.Serializable;public class UserBean implements Serializable{private static final long serialVersionUID = 1L;public UserBean() {}private Integer userId;private String userName;public Integer getUserId() {return userId;}public void setUserId(Integer userId) {this.userId = userId;}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}}

              ?

              ?

              MyComparator.java

              ?

              ?

                package com.rao.comparator;import java.util.Comparator;public class MyComparator implements Comparator<Integer> {public int compare(Integer o1, Integer o2) {int c = o1.compareTo(o2); return c;//可以完成顺序排序//return -c;//可以完成倒序排序}}

                ?

                ?运行结果,附上图片:

                ?


                Struts2.1 标签详细说明(二)
                ?

                ?
                Struts2.1 标签详细说明(二)
                ?
                Struts2.1 标签详细说明(二)
                ?
                Struts2.1 标签详细说明(二)
                ?
                Struts2.1 标签详细说明(二)
                ?
                Struts2.1 标签详细说明(二)
                ?
                Struts2.1 标签详细说明(二)
                ?

                ?

                ?

                ?

                ?代码见附件压缩包:Struts2-Tags.zip。谢谢!

                ?http://www.iteye.com/topic/655025

热点排行