zoukankan      html  css  js  c++  java
  • Struts(2) Struts2 详细配置

                   Struts2的配置  

                全局配置:

    配置在packe中,所有action的上面。

    <global-results>

    <result name="名字">/页面</result>

        <result name="名字">/页面</result>

    </global-results>

    局部结果优先级高于全局。

    异常信息配置:

    <global-exception-mappings>

    <exception-mapping result="error" exception="java.lang.

    Exception" />

    </global-exception-mappings>

    404异常、500异常(web.xml配置)

    <error-page>

       <error-code>404</error-code>

       <location>/error.jsp</location>

    </error-page>

      

    <error-page>

       <error-code>500</error-code>

       <location>/error.jsp</location>

    </error-page>

              包(package)配置:

    所有的action配置,都必须在包中。

    <package name=”mypk” extends=”struts-default” namespace=”/”>

     

    <action name=”” class=”” method=””>

     

          <result name=”” type=””>/jsp页面路径</result>

     

    </action>

     

    </package>

     

    注意:Action中的name属性可以使用模糊匹配。使用“*

          一般规则:name=“名字_*”  method=”{1}”

    示例:<action name="user_*" class="com.zuxia.action.UserInfoAction" method="{1}" />

    动态方法调用:根据用户的请求地址,调用指定的方法。

    语法规则:action!方法名.action

    <result name=””  type=”默认|redirect|redirectAction”>

    默认—— 表示内部跳转

    redirect —— 外部跳转

    redirectAction —— 跳转到指定的Action(必须设置两个参数:namespaceactionName

                                       注意:<action method=”默认方法execute”>   <result name=”默认为success”>

     

     

     

     

                系统常量配置(环境配置):

    <constant name=”常量名” value=”常量值” />

    所有struts的常量:struts2-core-x.x.x.jar 包中的default.properties

    struts.i18n.encoding=UTF-8  系统编码

    struts.objectFactory = spring  struts与spring框架结合时设置

    struts.devMode = false   启用struts的调试信息(详细更详细的错误信息)

    struts.multipart.maxSize=2097152   设置文件上传大小

    struts.custom.i18n.resources=资源文件名  国际化时,指定资源文件

  • 相关阅读:
    元音字母
    最近使用LINQ遇到的故障
    ASP.NET 2.0下实现匿名用户向注册用户的迁移(下)
    ASP.NET MVC 2配置使用CKEditor编辑器
    ASP.NET 角色及成员管理(entry 'AspNetSqlMembershipProvider' has already been added错误的解决)
    为什么Firefox 3及之后的版本不能加载本地的JavaScript文件了?
    在ASP.NET MVC中使用DropDownList
    LINQ entityset 不包含GetEnumerator的定义,在MVC中使用entity framework(EF)出现“必须添加对程序集“System.Data.Entity”解决方法
    去除element.style样式
    判断ViewData[""]是否为空
  • 原文地址:https://www.cnblogs.com/huzi007/p/2775395.html
Copyright © 2011-2022 走看看