nKognito
nKognito

Reputation: 6363

tomcat + spring mvc: trimSpaces

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

Upvotes: 0

Views: 2057

Answers (2)

Elvan
Elvan

Reputation: 621

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>

Trim Spaces in your JSP's

Upvotes: 1

MarcFasel
MarcFasel

Reputation: 1158

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.

Upvotes: 1

Related Questions