本文介绍了删除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上获得的一个例子: $ b

Here an example of what i get on Glassfish 4.0:



<%@ page trimDirectiveWhitespaces="true"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/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" "http://www.w3.org/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>





<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/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变量之间的间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 23:41