2016-12-06 65 views
0

有一個問題,這個JSP之間的間距要求JSP變量之間的間距取出

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

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

</tr> 

在屏幕有它們之間的空間,我想刪除。 有人可以幫我嗎?

P.S.我試過CSS和其他格式,但仍然沒有。

PS2:這是一個HTML頁面和getTextInput這是「創造」一個盒子

+1

嘗試呼應他們在單行之間的空格...沒有任何換行符 – RohitS

+0

我試過,仍然沒有 –

+0

你嘗試打印不變之前修剪? – VirtualTroll

回答

1

您可以使用該指令trimDirectiveWhitespaces

<%@ page trimDirectiveWhitespaces="true"%> 

這應該刪除的動作之間的白色空間的功能,腳本和指令。

這裏是我所得到的Glassfish的4.0個例子:在JSP

<%@ 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> 

源代碼

與<%@頁trimDirectiveWhitespaces = 「真正的」 %>在瀏覽器中收到:

<!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> 

與前述相同的JSP代碼但與<%@頁trimDirectiveWhitespaces = 「假」 %>
或者而不trimDirectiveWhitespaces在所有
產生在瀏覽器接收到如下因素的代碼:

<!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標籤