首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Struts2 Map值的传送与接收

2012-12-23 
Struts2 Map值的传递与接收原文地址:http://hi.baidu.com/%CE%E4%BA%BAjava%C5%E0%D1%B5/blog/item/012b6d

Struts2 Map值的传递与接收
原文地址:http://hi.baidu.com/%CE%E4%BA%BAjava%C5%E0%D1%B5/blog/item/012b6dc169ff489fc91768f5.html
<%
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 'index.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">
</head>

<body>
  <form action="map!test">
   <input type="text" name="map['name']">
   <input type="text" name="map['password']">
   <input type="submit">
  </form>
</body>
</html>

2.1 接受值页面 success.jsp

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ 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 'success.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">
</head>

<body>
  <s:iterator value="map" var="ha">
   <s:property value="#ha.key" />:<s:property value="#ha.value" /><br/>
  </s:iterator>
</body>
</html>

热点排行