此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【yingShisscWang】截止到2008-07-17 14:33:20的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:1 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
楼主【yingShisscWang】截止到2008-07-17 14:33:20的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:1 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
private static final long serialVersionUID = 2884782993925418103L; protected static String logger = Constants.COMMONS;// LogHandler.getLogger(getClass()); private String beanName = null; private String scope = null; // 对参数进行筛选的前缀字段,一般表单参数会以prefix为前缀,但是实际Bean属性或Map存储的名字没有prefix,所以在属性处理时需要剔除掉prefix。
private String prefix = "search_"; private Object bean = null; private boolean fromRequest = false; /**
* Sets bean names with value of the "bean" attribute.
*
* @param v
* bean names
*/
public void setBean(String v) {
beanName = v;
} /**
* Gets bean names.
*
* @return bean names
*/
public String getBean() {
return beanName;
} public String getPrefix() {
return prefix;
} public void setPrefix(String prefix) {
this.prefix = prefix;
} /**
* Sets the value of "scope" attribute, that represent beans scope.
*
* @param v
*/
public void setScope(String v) {
scope = v;
} /**
* Return value of the "scope" attribute
*
* @return bean scopes
*/
public String getScope() {
return scope;
} /**
* Copies properties of all specified bean into one map.
*
* @return EVAL_BODY_AGAIN
*/
public int doStartTag() {
if ("request".equals(beanName))
fromRequest = true;
if (!fromRequest) {
scope.toLowerCase(); HttpServletRequest request = (HttpServletRequest) pageContext
.getRequest();
HttpSession session = (HttpSession) pageContext.getSession(); if ((scope.length() == 0) || (scope.equals("page"))) {
bean = pageContext.getAttribute(beanName);
} else if (scope.equals("request")) {
bean = request.getAttribute(beanName);
} else if (scope.equals("session")) {
bean = session.getAttribute(beanName);
}
}
return EVAL_BODY_AGAIN;
} /**
* Performs smart form population.
*
* @return SKIP_BODY
*/
public int doAfterBody() {
BodyContent body = getBodyContent(); try {
JspWriter out = body.getEnclosingWriter();
String bodytext = body.getString(); if (bean != null || fromRequest == true) {
bodytext = populateForm(bodytext, bean);
}
out.print(bodytext);
} catch (Exception ex) {
ex.printStackTrace();
} return SKIP_BODY;
} /**
* End of tag.
*
* @return EVAL_PAGE
*/
public int doEndTag() {
return EVAL_PAGE;
} private String populateForm(String html, Object bean) {
int i = 0;
int s = 0; StringBuffer result = new StringBuffer(html.length());
String currentSelectName = null;
HttpServletRequest request = (HttpServletRequest) pageContext
.getRequest(); while (true) {
// find starting tag
i = html.indexOf('<', s);
if (i == -1) {
result.append(html.substring(s));
break; // input tag not found
}
result.append(html.substring(s, i)); // tag found, all before tag
// is stored
s = i;
// find closing tag
i = html.indexOf('>', i);
if (i == -1) {
result.append(html.substring(s));
break; // closing tag not found
}
i++;
try {
// match tags
String tag = html.substring(s, i);
String tagName = HtmlUtil.getTagName(tag);
if (tagName.equalsIgnoreCase("input") == true) { String tagType = HtmlUtil.getAttribute(tag, "type");
if (tagType != null) {
tagType = tagType.toLowerCase();
String name = HtmlUtil.getAttribute(tag, "name");
if (name == null) {
name = HtmlUtil.getAttribute(tag, "id");
}
if (prefix != null && prefix.length() > 0
&& name != null && name.startsWith(prefix)) {
name = name.substring(prefix.length(), name
.length());
}
String value = getValueFromReq(bean, request, name);
if (value != null) { if (tagType.equals("text")) {
tag = HtmlUtil
.addAttribute(tag, "value", value);
}
if (tagType.equals("hidden")) {
tag = HtmlUtil
.addAttribute(tag, "value", value);
}
if (tagType.equals("image")) {
tag = HtmlUtil
.addAttribute(tag, "value", value);
}
if (tagType.equals("password")) {
tag = HtmlUtil
.addAttribute(tag, "value", value);
}
if (tagType.equals("checkbox")) {
String tagValue = HtmlUtil.getAttribute(tag,
"value");
if (tagValue == null) {
tagValue = "true";
} if (tagValue.equals(value)) {
tag = HtmlUtil.addAttribute(tag, "checked");
}
}
if (tagType.equals("radio")) {
String tagValue = HtmlUtil.getAttribute(tag,
"value"); if (tagValue != null) {
if (tagValue.equals(value)) {
tag = HtmlUtil.addAttribute(tag,
"checked");
}
}
}
}
}
} else if (tagName.equalsIgnoreCase("textarea") == true) {
String name = HtmlUtil.getAttribute(tag, "name");
if (name == null) {
name = HtmlUtil.getAttribute(tag, "id");
}
if (prefix != null && prefix.length() > 0 && name != null
&& name.startsWith(prefix)) {
name = name.substring(prefix.length(), name.length());
}
String value = getValueFromReq(bean, request, name);
if (value != null) {
tag += HtmlEncoder.encode(value);
}
} else if (tagName.equalsIgnoreCase("select") == true) {
currentSelectName = HtmlUtil.getAttribute(tag, "name");
if (currentSelectName == null) {
currentSelectName = HtmlUtil.getAttribute(tag, "id");
}
if (prefix != null && prefix.length() > 0
&& currentSelectName != null
&& currentSelectName.startsWith(prefix)) {
currentSelectName = currentSelectName.substring(prefix
.length(), currentSelectName.length());
}
} else if (tagName.equalsIgnoreCase("/select") == true) {
currentSelectName = null;
} else if (tagName.equalsIgnoreCase("option") == true) {
if (currentSelectName != null) {
String tagValue = HtmlUtil.getAttribute(tag, "value");
String value = getValueFromReq(bean, request,
currentSelectName);
if (tagValue != null) {
if (value != null) {
if (value.equals(tagValue)) {
tag = HtmlUtil
.addAttribute(tag, "selected");
}
}
}
}
}
result.append(tag);
s = i;
} catch (Exception e) {
s = i;
LogHandler.error(logger,
"Form inner Tag is error,maybe is tag no name or id!",
e);
}
}
return result.toString();
} private String getValueFromReq(Object bean, HttpServletRequest request,
String name) throws IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
String value = null;
if (name != null) {
if (!fromRequest) {
if (bean instanceof Map) {
Map map = (Map) bean;
value = (String) map.get(name);
} else {
value = BeanUtils.getProperty(bean, name);
}
} else
value = request.getParameter(name); }
return value;
}
}
<logic:iterate id="p" name="infoForm" property="persons" indexId="index">
<html:text property="persons[${index}].name" value = "<%=p.getName()%>"/>
</logic:iterate>
<html:submit/> <html:cancel/>
</html:form> 改成如上即可