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=资源文件名  国际化时,指定资源文件

  • 相关阅读:
    jQuery offset获取坐标不精确的问题
    RPG Maker VX地图随机气泡对话 Ver1.0
    Qt绘图控件qwt绘制等比例坐标图
    Java服务端极光推送整合Ios、Android
    Jpush给 iOS 平台推送 title 值失败
    java之Hibenate中监听事件的重写和二级cache缓存
    java之Hibeante中SQL语句的使用
    Hibernate注解符合主键关联关系、持久化传播、继承映射
    hibernate之数据库注解关联关系
    hibernate(四) 双向多对多映射关系
  • 原文地址:https://www.cnblogs.com/huzi007/p/2775395.html
Copyright © 2011-2022 走看看