background image

统的框架,但它不强迫你必须在每一层中必须使用 Spring,因为它模块化的很好,允许你根据自己的
需要选择使用它的某一个模块;

         采用 IoC 使 得可 以 很容 易 的实 现 bean 的装 配, 提 供了 简 洁的 AOP 并 据此 实 现事 务 管理
(Transcation Managment),

 

等等

 
3.

struts 与 spring 是如何继承的

    不懂题目之意:是否是说的 struts 的 action 都继承自 org.apache.struts.action.Action
    而 Spring 中的继承就不清楚了。

4.

struts 如何实现国际化

    以下以两国语言(中文,英文)为例:
    1. 在工程中加入 Struts 支持
        2.   编 辑 ApplicationResource.properties 文 件 , 在 其 中 加 入 要 使 用 国 际 化 的 信 息 ,   例 如 : 
lable.welcome.china=Welcome!!!
    3. 创建英文资源文件 ApplicationResource_en.properites
    4. 创建临时中文资源文件 ApplicationResource_temp.properites 例如:lable.welcom.china=
中国欢迎您!
    5. 对临时中文资源文件进行编码转换。可以使用 myeclipse 的插件,也可以在 dos 下执行:
              native2ascii   -encoding   gb2312   ApplicationResource_temp.properties 
ApplicationResource_zh_CN.properties
        6.   在 jsp 中 加 入 struts 的 bean

 

标 记 库 <%@   taglib   uri="/WEB-INF/struts-bean.tld" 

prefix="bean"%>
       

 

显示信息: <bean:message key="label.welcome.china">

可以在 struts-config.xml 文件中定义多个资源包,而每个资源包可使用 key 属性指定包的名称。

5.

struts2.0 的常用标签

    1. 往 action 里传值:<input name="userName" type="text" class="input6" size="15"> 
    2. 

 

显示标签 property 用于输出指定值:<s:property value="userName "/>

    3.   用 于 从 页 面 往 action 中 (user) 的 对 象 内 传 值 : <s:text   name="user.userName   " 
id="username"/> 
    4. 判断<s:if> </s:if> 

 

用于在页面中判断指定数据 <s:if test="userName == admin">…. 

</s:if> <s:else>…. </s:else>
    5. 迭代<s:iterator>用于将 List、Map、ArrayList

 

等集合进行循环遍历

       <s:iterator value="userList" id="user" status="u"> 
          <s:property value="userName"/></a> 
       </s:iterator> 
    6. URL 地址标签,<s:url>用于生成一个 URL 地址,可以通过 URL 标签指定的<s:param>子元素
向 URL

 

地址发送请求参数

       <s:url action=" "> 
          <s:param name=" " value=""></s:param> 
       </s:url>
    7. 

 

超链接 <a href >一般和<s:url>

 

标签一起使用,用于带多个参数。

       <a href=" 
          <s:url action=" "> 
             <s:param name=" " value=""></s:param> 
             <s:param name=" " value=""></s:param>