zoukankan      html  css  js  c++  java
  • struts2.1.6中的注意事项

    不晓得是不是struts2版本的问题,小的初学,在使用struts2.1.6中遇到不少问题,不知道大家有没有遇到

    1.与struts2.0.14不同,要想正常使用struts2.1.6,至少需要6 个jar包:

    struts2-core-2.1.6.jar

    freemarker-2.3.13.jar

    commons-logging-1.0.4.jar

    ognl-2.6.11.jar

    xwork-2.1.2.jar

    commons-fileupload-1.2.1.jar

    2. 今天在使用零配置( zero configuration)的时候按照struts2.0.14中那样在sturts2-core-2.0.11中org.apache.struts2.config下找了半天都没有那个包,上网才晓得“struts2.1.6中还需要引用struts2-convention-plugin-2.1.6.jar文件,而且注释类的包也变了(又增加了一些新的注释类),Struts2.0.14中的注释类在org.apache.struts2.config包中,而struts2.1.6的注释类在 org.apache.struts2.convention.annotation包中。除此之外,有些注释的属性名也变了,如Result注释在 struts2.0.14中有一个value属性,表示一个要转入的URL,而

    Struts2.1.6的Result注释中使用location属性代替了value属性(不再有value属性了),但它们的使用方法相同。”

    3.记得在struts2.0.14中,@result中type为类名,然后利用反射机制装载这个类例如type=org.apache.struts2.dispatcher.ServletRedirectResult.class,而struts2.1.6中type应填入名称如type="redirect",否则会报错。

    4.在action包设置的时候<package name="action" extends="struts-default" namespace="/">如果缺省namespace就会报错,找不到result。这种错误一定要注意,通常这种错误很隐蔽,提示找不到result对应该资源文件,一般的考虑是struts.xml加载失败或者是web.xml配置错误等问题很少会想到是namespace的错误。所以这种错误一定要注意。

    5.在一个action返回result访问另一个package中的action时:<result  type="chain">/xxx/test</result>来访问<action name="test" namespace="/xxx"会报错,找不到这个action,但是如果改成

    <result type="chain">
       <param name="actionName">test</param>
       <param name="namespace">/xxx</param>
       </result>

    这种方法来访问就没有问题。

    以上是我自己使用的结果,不知道大家遇没遇到同样的问题,是不是struts2.1.6版本的问题呢

  • 相关阅读:
    IE6中overflow:hidden失效怎么办
    单例模式笔记
    linux 中的 "2>&1"含义
    linux 文件目录介绍
    centos 安装jdk
    SimpleDateFormat非线程安全
    Linux下Weblogic 11g R1安装和配置
    <meta>标签 的一些用法
    基于java的邮件群发软件
    史上最完整的集合类总结及hashMap遍历
  • 原文地址:https://www.cnblogs.com/moonfans/p/2985303.html
Copyright © 2011-2022 走看看