1
1
/*
2
- * Copyright 2002-2016 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
28
28
import org .springframework .beans .PropertyAccessor ;
29
29
import org .springframework .core .Conventions ;
30
30
import org .springframework .http .HttpMethod ;
31
+ import org .springframework .util .CollectionUtils ;
31
32
import org .springframework .util .ObjectUtils ;
32
33
import org .springframework .util .StringUtils ;
33
34
import org .springframework .web .servlet .support .RequestDataValueProcessor ;
@@ -666,7 +667,7 @@ private String processAction(String action) {
666
667
public int doEndTag () throws JspException {
667
668
RequestDataValueProcessor processor = getRequestContext ().getRequestDataValueProcessor ();
668
669
ServletRequest request = this .pageContext .getRequest ();
669
- if (( processor != null ) && ( request instanceof HttpServletRequest ) ) {
670
+ if (processor != null && request instanceof HttpServletRequest ) {
670
671
writeHiddenFields (processor .getExtraHiddenFields ((HttpServletRequest ) request ));
671
672
}
672
673
this .tagWriter .endTag ();
@@ -677,7 +678,7 @@ public int doEndTag() throws JspException {
677
678
* Writes the given values as hidden fields.
678
679
*/
679
680
private void writeHiddenFields (Map <String , String > hiddenFields ) throws JspException {
680
- if (hiddenFields != null ) {
681
+ if (! CollectionUtils . isEmpty ( hiddenFields ) ) {
681
682
this .tagWriter .appendValue ("<div>\n " );
682
683
for (String name : hiddenFields .keySet ()) {
683
684
this .tagWriter .appendValue ("<input type=\" hidden\" " );
@@ -694,6 +695,7 @@ private void writeHiddenFields(Map<String, String> hiddenFields) throws JspExcep
694
695
@ Override
695
696
public void doFinally () {
696
697
super .doFinally ();
698
+
697
699
this .pageContext .removeAttribute (MODEL_ATTRIBUTE_VARIABLE_NAME , PageContext .REQUEST_SCOPE );
698
700
if (this .previousNestedPath != null ) {
699
701
// Expose previous nestedPath value.
0 commit comments