I am trying to use Tomcat's trimSpaces attribute, but the problem is that with Spring it doesn't work. I wanted to use some Spring method insted and found this question, but my application fails with exception (please see the last comments of best answer). Thank you
Asked
Active
Viewed 2,009 times
2 Answers
1
The trimSpaces attribute of Tomcat does not trim spaces from form fields. It is used to remove white spaces around JSP tags. If this is your JSP file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@page session="false"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<head>
it will render client-side as
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
With the Tomcat trimSpaces=true it will look like
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
The whitespaces around the JSP tags are trimmed. This does not sound like the thing yuo want.

MarcFasel
- 1,080
- 10
- 19
-
Actually, this is what I need. But the problem that if I add such attribute to web.xml (of tomcat, not of application) - nothing happens. May be it is because of Spring MVC? – nKognito Mar 29 '12 at 09:14
1
Put this in application's web.xml
.
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>

Elvan
- 621
- 3
- 4