struts2 tags for request

2011-04-25  来源:本站原创  分类:Java  人气:76 

Get the request in the Action Method One:

In the Action code:
Map request = (Map) ActionContext.getContext (). Get ("request");
List <Task> tasks = taskManager.findAll ();
request.put ("tasks", tasks);

In the JSP page for which the values:
<s:iterator value="#request.tasks">
<tr>
<td> <s:property value="#task.tname"/> </ td>
<td> <s:property value="#task.tuid"/> </ td>
<td> <s:property value="#task.tstartTime"/> </ td>
<td> <s:property value="#task.tendTime"/> </ td>
<td> <s:property value="#task.tstate"/> </ td>
<td> <input type = "radio" name = "choose" value = "<s:property value='#task.tid'/> "/></ td>
</ Tr>
</ S: iterator>
-------------------------------------------------- ------------------------------------------
Method two: to obtain by ServletActionContext class

Action code:
HttpServletRequest request = ServletActionContext.getRequest ();
request.setAttribute ("username", "zhangsan");

Get them in the value of jsp
<s:property value="#request.username"> or $ {requestScope.req}
-------------------------------------------------- ------------------------------------------
Method three: by ServletRequestAware interface through the IOC into the Request object mechanism
Action code:
Action to achieve ServletRequestAware interface, the method that implements the interface
private HttpServletRequest request;
/ / Implement interface methods
public void setServletRequest (HttpServletRequest request) {
this.request = request;
}
/ / And then execute () method can be used to
public String execute () {
request.setAttribute ("username", "zhangsan");
request.getSession (). getServletContext (). getApplication (); / / get Application
}
This method must be implemented and that the method is automatically called this method is called the process, will create a good way to request object parameter passed to you, you can use to assign your variables in this class, Then you can use the attention request: setServletRequest () method will be execute () method is called before the execution

Jsp page in which the value obtained
<s:property value="#request.task.tname"/>

相关文章
  • struts2 tags for request 2011-04-25

    Get the request in the Action Method One: In the Action code: Map request = (Map) ActionContext.getContext (). Get ("request"); List <Task> tasks = taskManager.findAll (); request.put ("tasks", tasks); In the JSP page for which t

  • Struts2 tags commonly used in developing the page 2010-04-17

    Struts2 labels commonly used in developing the use of page description 1.1. To the action where the use-value method: <input name="userName" type="text" size="15"> a. userName attribute to access the action need to prov

  • The basic use Struts2 tags (2) transfer: 2010-03-16

    From: http://stanlyy.javaeye.com 1: output action in the attribute value to display in jsp page using: <s:property value=" The attribute name " /> 2: In the page number to automatically increase the statuts of the index with iterator prope

  • struts2 tags help documentation (struts2-tags-API) 2010-08-19

    struts2 tags help documentation (struts2-tags-API)

  • Struts2 tags to determine the strings are equal and struts2 tag library 2010-12-26

    Doing the project, the need to determine with struts2 tags to determine whether two strings are equal, the access to relevant information, find the following methods The correct wording is as follows: <s:if test='#user.userSex == "M"'> M &

  • struts2 tags using one of the s: if 2010-03-29

    struts2 of the web in order to facilitate the preparation of the project jsp, tag is the best option 1: struts2 tag library defined in the **- core-version number. Jar META-INF path to find struts-tags.tld files; use of the label web project which ne

  • Struts2 tags to implement custom paging 2010-10-29

    Struts2 in a custom label is very simple to achieve, is divided into three steps: 1. Create taglib file (. Tld), the preparation of labeling statements. 2. Write a custom tag class. 3. In the page using the tag. The following page to a custom tag, fo

  • struts2 get the request response session object 2008-08-10

    1, non-IoC approach To obtain the above-mentioned objects, the key to Struts 2 in com.opensymphony.xwork2.ActionContext class. We can, through its static method getContext () Get the context of the current Action object. With this object we want to g

  • struts2 tags using <s:filederror/> detailed error messages output format control 2010-07-07

    Keyword: struts2 tag fielderror error message format Feelings: do early in the project, get a 500 error page is always reported, but the background did not have any output error messages, it is depressed, The last check, the original struts were in t

  • Struts2 session and request access 2010-07-15

    struts provide two ways to access session and request, some of the more common is the use of inside SPRING IOC said that inversion of control IOC by: action class implements ServletRequestAware interface and create a new HttpServletRequest request pu

  • Struts2 Session and request objects obtained in two ways 2010-09-15

    In struts2 in, request and session are hidden struts provide two ways to access session and request, some of the more common is the use of inside SPRING IOC said that inversion of control IOC by: action class implements ServletRequestAware interface

  • struts2 access session request.response and methods 2010-10-12

    In struts1, access to the system is very easy to request or session objects are passed by parameter, but in struts2 in, request and session are hidden struts provides two ways to access session and request, one of the more common is the use of SPRING

  • The <s:password> struts2 tags ... 2010-12-26

    <s:password> Tag is encountered with a strange phenomenon, that is when to get the password from the database with <s:password> label is displayed, shown in <s:password> is empty. Instead of showing the password "***" form. I a

  • Several options struts2 tags 2011-05-04

    Struts2 for a long time to learn, always felt good with his label, here are a few options Tags: The following classes will use a book, and getBooks by way of the end of this article will be provided. 1, <s:select/> <s:form> <!-- Using a sim

  • Struts2 tags to obtain the value of requestURI.contextPath 2010-02-12

    Gets the contextPath <s:property value="#request.get('javax.servlet.forward.context_path')" /> Gets the requestURI <s:property value="#request.get('javax.servlet.forward.request_uri')" />

  • datetimepicker struts2 tags 2010-03-29

    1.struts2-dojo-plugin-2.1.6.jar to introduce into their own projects. 2.jsp by adding the following <% @ Page language = "java" pageEncoding = "UTF-8"%> <% @ Taglib prefix = "s" uri = "/ struts-tags"%> &

  • struts2 tags related to the use of the iterator 2010-04-16

    In explaining the s: iterator tag used before to understand the next struts2 in the Value Stack. Here webwork references in the description of the Value Stack, because struts2 is upgraded on the basis of webwork, so webwork for Value Stack formulatio

  • (Transfer) struts2 tags that use the iterator method 2009-10-02

    As the programming I just want to traverse a two-dimensional array, found the following article, reproduced with come, and which, among two-dimensional array of partially successful authentication, the other not been verified, the provisional collect

  • struts2 tags used two s: iterator 2008-11-19

    struts2 of the s: iterator to traverse the data inside the stack of any array, collection, and so following a few simple demo: s: iterator tag has three attributes: value: being a collection of iterative id: the element inside the specified collectio

  • Struts2 <s:if test> Tags 2010-01-24

    1 struts2 <s:if> compare the size of the test <s:if test="%{maxNewsId!=news.newsId}"> **maxNewsId And it is in the news Action Getter and in setter Methods, by Action Passes