import java.util.List;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;
static private List<BookDao> books = new ArrayList<BookDao>();
static {
BookDao book1 = new BookDao();
BookDao book2 = new BookDao();
BookDao book3 = new BookDao();
book1.setBookID("001");
book1.setBookName("book001");
book2.setBookID("002");
book2.setBookName("book002");
book3.setBookID("003");
book3.setBookName("book003");
books.add(book1);
books.add(book2);
books.add(book3);
}
public String execute() {
ActionContext ctx = ActionContext.getContext();
Map session = ctx.getSession();
session.put("selectList", books);
return SUCCESS;
}
return books;
}
TestAction.books = books;
}
------------------------------------------------------
import com.opensymphony.xwork2.ActionSupport;
final String HTTP_REQUEST = org.apache.struts2.StrutsStatics.HTTP_REQUEST;
public String execute() {
ActionContext ctx = ActionContext.getContext();
HttpServletRequest req = (HttpServletRequest) ctx.get(HTTP_REQUEST);
Map session = ctx.getSession();
session.put("key", req.getParameter("incision1"));
return SUCCESS;
}
}
------------------------------------------------------------------
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<body>
<s:form action="testAction">
<s:submit>OK</s:submit>
</s:form>
</body>
</html>
---------------------------------------------------------------------
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'testResult.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<body>
<body>
<s:form action="test2Action">
<s:select name="incision1" list="books" listKey="bookID" listValue="bookName"
headerKey="" headerValue=" - " multiple="false" theme="simple">
</s:select>
<s:submit>kk</s:submit>
</s:form>
</body>
</html>
----------------------------------------------------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test2Result.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
!!!
${sessionScope.key}
!!!
</body>
</html>
---------------------------------------------------------------------------