代码之家  ›  专栏  ›  技术社区  ›  user1459961

struts2+jquery插件+tiles插件:如何更改远程div?

  •  0
  • user1459961  · 技术社区  · 13 年前

    我正在尝试学习如何使用远程分区,所以我一直在查看struts2 jquery插件的展示,但我不太了解它是如何工作的。以下是他们下载的内容:

    struts.xml:

    <struts>
        // some other instructions and constants
        <include file="showcase.xml" />
    </struts>
    

    showcase.xml:(应该是空的吗??)

    <struts>
        <package name="showcase" extends="struts-default,json-default" namespace="/">
        </package>
    </struts>
    

    远程分区.java:

    package com.jgeppert.struts2.jquery.showcase;
    
    import org.apache.struts2.convention.annotation.Action;
    import org.apache.struts2.convention.annotation.ParentPackage;
    import org.apache.struts2.convention.annotation.Result;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    @ParentPackage(value = "showcase")
    public class RemoteDiv extends ActionSupport {
    
      private static final long serialVersionUID = -6793556760537290969L;
    
      @Action(value = "/remote-div", results = {
        @Result(location = "remote-div.jsp", name = "success")
      })
      public String execute() throws Exception
      {
        return SUCCESS;
      }
    }
    

    所以我的问题是:

    1) 注释@Action是强制性的还是替换了我们应该在struts.xml中声明的操作?

    2) 什么是 /远程div 关于我们应该在struts.xml中提到的动作的名称??

    3) 就我而言,我正在使用 瓷砖 ,我应该执行location=“mypage.tiles”吗?我指的是tiles.xml中给页面的名称?

    4) 怎么样 @ParentPackage(value=“showcase”) ,我们是否应该只提及父包的名称而不提及整个路径??

    5) 在这种情况下,我需要 json插件 ?

    如果我的问题很愚蠢的话,我会提前说错话。但请理解我,伙计们,我还是个初学者。提前表示衷心的感谢!

    1 回复  |  直到 13 年前
        1
  •  0
  •   Dave Newton    13 年前
    1. 这是动作映射注释。操作必须以某种方式通过注释、XML配置和约定(即约定或REST插件)进行映射。
    2. 这是行动的名称。不通过注释定义操作 XML–选择一个。
    3. 是的,您需要定义结果类型,或者使用tile作为默认结果类型。
    4. 这是S2包的名称,即 <package> 在配置文件中。
    5. 在您想要JSON结果的情况下。

    关于您的问题“包裹声明是否应该为空”——仅当您希望其为空时。它定义了一个包,以及与包相关的各种内容(如拦截器堆栈、结果类型、结果、URL的第一部分等)