• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lessthan symbol automatically converted to "& lt ;" when passed to JSP

 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone

I am trying to find a reason for this.

I have created a Spring MVC project.
A map "conMap" is set in model attribute having values <34, >=34.

In JSP, dropdown is being populated like this

While doing view page source in browser, I found that lessthan symbol is replaced by "& lt ;" and so on.
But if I am creating a normal dropdown(not spring form:select) and populating the values in forEach loop from the same map, lessthan symbol is not replaced by "& lt ;"

Can anyone help me in finding the reason?

Thanks
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the spring-mvc source code, the form tag handler makes a call to evaluate each value of item; subsequently a call is made to
Htmlutils as below
ValueFormatter.getDisplayString(value, isHtmlEscape());

Here each character of item is checked for any encoding and therefore any special html characters are converted, thats why you see the value replaced.

There is an option for enable/disable html escaping,Have a look at the select taglib,
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/spring-form.tld.html#spring-form.tld.select
reply
    Bookmark Topic Watch Topic
  • New Topic