删除JSP变量之间的间距

编程入门 行业动态 更新时间:2024-10-24 15:17:48
本文介绍了删除JSP变量之间的间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这个jsp调用之间的间隔有问题

have a problem with the spacing between this jsp calls

<tr> <%=Constants.getTextInput("", Texts.RNG_IDENT_MSG, "", "", 19)%> <%=Constants.getTextInput("", Texts.RNG_IDENT_MSG_UNTIL, "", "", 19)%> </tr>

在屏幕中间有一个空格,我想删除它。 有人可以帮我吗?

In the screen there's a space between them, that i want to remove. Can someone help me?

我试过css和其他格式,但仍然没有。

P.S. i tried css and other formats but still nothing.

PS2:这是一个HTML页面,getTextInput它是一个函数来创建一个盒子。 b $ b

P.S.2: This is in a HTML page and getTextInput it's a function to "create" a box

推荐答案

您可以使用指令 trimDirectiveWhitespaces $ b

You can use the directive trimDirectiveWhitespaces

<%@ page trimDirectiveWhitespaces="true"%>

这应该会消除动作,脚本和指令之间的空白。

This should remove white spaces between actions, scriptlets and directives.

下面是我在Glassfish 4.0上获得的一个例子:

Here an example of what i get on Glassfish 4.0:

with<%@ page trimDirectiveWhitespaces = jsp中的true%>

with <%@ page trimDirectiveWhitespaces="true"%> in the jsp

<%@ page trimDirectiveWhitespaces="true"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="java.sun/jsp/jstl/core" prefix="c" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <table> <tr> <%="1111111111"%> <%="2222222222"%> <c:out value="c:out"></c:out> <c:out value="LOOP"></c:out> <c:forEach begin="1" end="5" step="1" var="y"> ${'qqqqq'} ${'RRR'} <c:out value="c:out"></c:out> <% out.println("InTheLoop"); %> </c:forEach> </tr> </table> </body> </html>

浏览器中收到的源代码:

Source code received in browser:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <table> <tr> 11111111112222222222c:outLOOPqqqqqRRRc:outInTheLoop qqqqqRRRc:outInTheLoop qqqqqRRRc:outInTheLoop qqqqqRRRc:outInTheLoop qqqqqRRRc:outInTheLoop </tr> </table> </body> </html>

与上面相同的JSP代码,但加上 或 without trimDirectiveWhitespaces 在所有 中生成浏览器中收到的以下代码:

The same JSP code as above but with <%@ page trimDirectiveWhitespaces="false"%> Or without trimDirectiveWhitespaces at all produce the folowing code received in browser:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <table> <tr> 1111111111 2222222222 c:out LOOP qqqqq RRR c:out InTheLoop qqqqq RRR c:out InTheLoop qqqqq RRR c:out InTheLoop qqqqq RRR c:out InTheLoop qqqqq RRR c:out InTheLoop </tr> </table> </body> </html>

所以trimDirectiveWhitespace =true:

  • 您可以删除动作,脚本,表达式,指令之间的空格。
  • 但是,您不能删除其他html标记之间的空格
  • you can remove whitespaces between actions, scriptlets, expressions, directives.
  • But you can NOT remove whitespaces between other html tags

更多推荐

删除JSP变量之间的间距

本文发布于:2023-11-12 01:06:36,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:间距   变量   JSP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!