提交 60ff93e5 编写于 作者: J Juergen Hoeller

avoid invalid id characters in ErrorsTag as well (SPR-6862)

上级 f25d2a94
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -25,6 +25,7 @@ import javax.servlet.jsp.tagext.BodyTag;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Form tag for displaying errors for a particular field or object.
......@@ -100,16 +101,6 @@ public class ErrorsTag extends AbstractHtmlElementBodyTag implements BodyTag {
}
/**
* Get the value for the HTML '<code>name</code>' attribute.
* <p>Simply returns <code>null</code> because the '<code>name</code>' attribute
* is not a validate attribute for the '<code>span</code>' element.
*/
@Override
protected String getName() throws JspException {
return null;
}
/**
* Get the value for the HTML '<code>id</code>' attribute.
* <p>Appends '<code>.errors</code>' to the value returned by {@link #getPropertyPath()}
......@@ -125,7 +116,17 @@ public class ErrorsTag extends AbstractHtmlElementBodyTag implements BodyTag {
path = (String) this.pageContext.getAttribute(
FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
}
return path + ".errors";
return StringUtils.deleteAny(path, "[]") + ".errors";
}
/**
* Get the value for the HTML '<code>name</code>' attribute.
* <p>Simply returns <code>null</code> because the '<code>name</code>' attribute
* is not a validate attribute for the '<code>span</code>' element.
*/
@Override
protected String getName() throws JspException {
return null;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册