ParaFormat.tag文件 |
<jsp:directive.tag language="java" pageEncoding="UTF-8"/> |
|
<%@ attribute name="name" required="true" %> |
<%@ attribute name="items" required="true" %> |
<% |
java.util.Map paraMap = new java.util.HashMap(); |
|
String[] names = items.split(","); |
for(int i=0;i<names.length;i++){ |
String name=names[i]; |
Object value = request.getAttribute(name); |
paraMap.put(name,value); |
} |
|
if(paraMap!=null||paraMap.size()>0){ |
String paraString = com.siaya.tag.Map64String.map2Base64(paraMap); |
request.setAttribute("_REQUEST_PARAM_DATA_", paraString); |
request.setAttribute("_FORMAT_STRING_NAME_",this.getName()); |
|
%> |
|
<input name="${_FORMAT_STRING_NAME_}" value="${_REQUEST_PARAM_DATA_}" type="hidden" /> |
|
<%}%> |
ParaParser.tag文件 |
<jsp:directive.tag language="java" pageEncoding="UTF-8"/> |
<%@ attribute name="name"%> |
<% |
String inputName = this.getName(); |
System.out.println("mapData"+inputName); |
String paramString = request.getParameter(inputName); |
|
if(paramString!=null){ |
java.util.Map mapData = com.siaya.tag.Map64String.base64ToMap(paramString); |
System.out.println("mapData"+mapData); |
for(Object oEntry:mapData.entrySet()){ |
java.util.Map.Entry entry = (java.util.Map.Entry)oEntry; |
String keyName = (String)entry.getKey(); |
Object value=entry.getValue(); |
request.setAttribute(keyName,value); |
} |
} |
%> |
|
保存页面中的值 向后台传输 序列化后的数据 |
<%@ taglib prefix="s" tagdir="/WEB-INF/tags"%> |
<s:ParaParser name="ModCusBaseInfoP"/>开始标签 |
<s:ParaFormat items="tcpBelief,tcpHobby" name="ModCusBaseInfoP"/>结束标签 |
item里面 是需要序列话的数据,用“,”分开 |
所有参数包含在起始结束标签中间 |
action.java中可以直接在request中取到tcpBelief和tcpHobby等值 |