File tree Expand file tree Collapse file tree 3 files changed +5
-8
lines changed
org.springframework.web.servlet/src
main/java/org/springframework/web/servlet/tags
test/java/org/springframework/web/servlet/tags Expand file tree Collapse file tree 3 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,6 @@ public int doEndTag() throws JspException {
99
99
Expression expression = this .expressionParser .parseExpression (this .expression );
100
100
EvaluationContext context = createEvaluationContext ();
101
101
if (this .var == null ) {
102
- // print the url to the writer
103
102
try {
104
103
String result = expression .getValue (context , String .class );
105
104
result = isHtmlEscape () ? HtmlUtils .htmlEscape (result ) : result ;
@@ -111,7 +110,6 @@ public int doEndTag() throws JspException {
111
110
}
112
111
}
113
112
else {
114
- // store the url as a variable
115
113
pageContext .setAttribute (var , expression .getValue (context ), scope );
116
114
}
117
115
return EVAL_PAGE ;
@@ -129,8 +127,7 @@ private EvaluationContext createEvaluationContext() {
129
127
130
128
private ConversionService getConversionService () {
131
129
try {
132
- // TODO replace this with a call to RequestContext that is not brittle
133
- return getRequestContext ().getWebApplicationContext ().getBean ("conversionService" , ConversionService .class );
130
+ return (ConversionService ) this .pageContext .getRequest ().getAttribute ("org.springframework.core.convert.ConversionService" );
134
131
} catch (BeansException e ) {
135
132
return null ;
136
133
}
Original file line number Diff line number Diff line change 18
18
19
19
import junit .framework .TestCase ;
20
20
21
- import org .springframework .format .support .FormattingConversionServiceFactoryBean ;
22
21
import org .springframework .mock .web .MockHttpServletRequest ;
23
22
import org .springframework .mock .web .MockHttpServletResponse ;
24
23
import org .springframework .mock .web .MockPageContext ;
@@ -44,8 +43,6 @@ protected MockPageContext createPageContext() {
44
43
SimpleWebApplicationContext wac = new SimpleWebApplicationContext ();
45
44
wac .setServletContext (sc );
46
45
wac .setNamespace ("test" );
47
- // TODO this name index leads to brittle lookup by EvalTag
48
- wac .registerSingleton ("conversionService" , FormattingConversionServiceFactoryBean .class );
49
46
wac .refresh ();
50
47
51
48
MockHttpServletRequest request = new MockHttpServletRequest (sc );
Original file line number Diff line number Diff line change 22
22
23
23
import org .springframework .format .annotation .NumberFormat ;
24
24
import org .springframework .format .annotation .NumberFormat .Style ;
25
+ import org .springframework .format .support .FormattingConversionServiceFactoryBean ;
25
26
import org .springframework .mock .web .MockHttpServletResponse ;
26
27
import org .springframework .mock .web .MockPageContext ;
27
28
@@ -33,6 +34,9 @@ public class EvalTagTests extends AbstractTagTests {
33
34
34
35
protected void setUp () throws Exception {
35
36
context = createPageContext ();
37
+ FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean ();
38
+ factory .afterPropertiesSet ();
39
+ context .getRequest ().setAttribute ("org.springframework.core.convert.ConversionService" , factory .getObject ());
36
40
context .getRequest ().setAttribute ("bean" , new Bean ());
37
41
tag = new EvalTag ();
38
42
tag .setPageContext (context );
@@ -53,7 +57,6 @@ public void testEndTagPrintFormattedScopedAttributeResult() throws Exception {
53
57
assertEquals (Tag .EVAL_BODY_INCLUDE , action );
54
58
action = tag .doEndTag ();
55
59
assertEquals (Tag .EVAL_PAGE , action );
56
- // TODO - fails because EL does not consider annotations on getter/setter method or field for properties (just annotations on method parameters)
57
60
//assertEquals("25%", ((MockHttpServletResponse)context.getResponse()).getContentAsString());
58
61
}
59
62
You can’t perform that action at this time.
0 commit comments