org.apache.struts2.components
类 Include

java.lang.Object
  继承者 org.apache.struts2.components.Component
      继承者 org.apache.struts2.components.Include

public class Include
extends Component

Include a servlet's output (result of servlet or a JSP page).

Note: Any additional params supplied to the included page are not accessible within the rendered page through the <s:property...> tag since no valuestack will be created. You can, however, access them in a servlet via the HttpServletRequest object or from a JSP page via a scriptlet.

Examples

 
 <-- One: -->
 <s:include value="myJsp.jsp" />

 <-- Two: -->
 <s:include value="myJsp.jsp">
    <s:param name="param1" value="value2" />
    <s:param name="param2" value="value2" />
 </s:include>

 <-- Three: -->
 <s:include value="myJsp.jsp">
    <s:param name="param1">value1</s:param>
    <s:param name="param2">value2</s:param>
 </s:include>
 

 
 Example one - do an include myJsp.jsp page
 Example two - do an include to myJsp.jsp page with parameters param1=value1 and param2=value2
 Example three - do an include to myJsp.jsp page with parameters param1=value1 and param2=value2
 
 


字段摘要
 
从类 org.apache.struts2.components.Component 继承的字段
COMPONENT_STACK
 
构造方法摘要
Include(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
方法摘要
 void addParameter(String key, Object value)
          Adds the given key and value to this component's own parameter.
 boolean end(Writer writer, String body)
          Callback for the end tag of this component.
static String getContextRelativePath(javax.servlet.ServletRequest request, String relativePath)
           
static void include(String relativePath, Writer writer, javax.servlet.ServletRequest request, javax.servlet.http.HttpServletResponse response)
          已过时。 use include(String, java.io.Writer, javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse, String) instead with correct encoding specified
static void include(String relativePath, Writer writer, javax.servlet.ServletRequest request, javax.servlet.http.HttpServletResponse response, String encoding)
          Include a resource in a response.
 void setDefaultEncoding(String encoding)
           
 void setValue(String value)
           
 
从类 org.apache.struts2.components.Component 继承的方法
addAllParameters, altSyntax, copyParams, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, start, usesBody
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

Include

public Include(com.opensymphony.xwork2.util.ValueStack stack,
               javax.servlet.http.HttpServletRequest req,
               javax.servlet.http.HttpServletResponse res)
方法详细信息

setDefaultEncoding

public void setDefaultEncoding(String encoding)

end

public boolean end(Writer writer,
                   String body)
从类 Component 复制的描述
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

覆盖:
Component 中的 end
参数:
writer - the output writer.
body - the rendered body.
返回:
true if the body should be evaluated again

setValue

public void setValue(String value)

getContextRelativePath

public static String getContextRelativePath(javax.servlet.ServletRequest request,
                                            String relativePath)

addParameter

public void addParameter(String key,
                         Object value)
从类 Component 复制的描述
Adds the given key and value to this component's own parameter.

If the provided key is null nothing happens. If the provided value is null any existing parameter with the given key name is removed.

覆盖:
Component 中的 addParameter
参数:
key - the key of the new parameter to add.
value - the value assoicated with the key.

include

public static void include(String relativePath,
                           Writer writer,
                           javax.servlet.ServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws javax.servlet.ServletException,
                           IOException
已过时。 use include(String, java.io.Writer, javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse, String) instead with correct encoding specified

抛出:
javax.servlet.ServletException
IOException

include

public static void include(String relativePath,
                           Writer writer,
                           javax.servlet.ServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           String encoding)
                    throws javax.servlet.ServletException,
                           IOException
Include a resource in a response.

参数:
relativePath - the relative path of the resource to include; resolves to getContextRelativePath(javax.servlet.ServletRequest, String)
writer - the Writer to write output to
request - the current request
response - the response to write to
encoding - the file encoding to use for including the resource; if null, it will default to the platform encoding
抛出:
javax.servlet.ServletException
IOException