2016-09-30 23 views
0

我在將一個newLine放入發送給.jspx文件的Java字符串時遇到了麻煩。 我有一個表格,並在一個單元格中顯示從控制器收到的字符串的內容爲:如何在標記表(Spring MVC)中創建新行?

| ------- |
| aaa |
| bbb |
| ------- |

取而代之我得到這個:
| ----------- |
| aaa bbb |
| ----------- |
與寫AAA和BBB之間的BR標籤(我有別的,因爲這個網站做一個換行符在我的例子..把它寫在這裏)

在java控制器的代碼是:

String a = "aaa"; 
    String b = "bbb"; 
    String cell= a +"<br/>"+ b; 
    model.addAttribute("cell",cell); 

我也試過(而不是BR標籤) 「\ n」 「\ r \ n」 和 「System.getProperty(」 line.separator 「)」 沒有成功

在.jspx我得到:

<table:table> 
    <table:column id="firstCellId" property="cell"> 
    ... 
    <table:column id="secondCellId" property="another column">//others tr cell of no importance.. 
    <table:column id="secondCellId" property="another column">//others tr cell of no importance.. 
</table:table> 

是有沒有辦法修改單元而不使用CSS?

回答

0

它是由引起:

htmlEscape變量表= 「假」

。我已經刪除它,現在它工作。

我不知道如何關閉這個問題。

0

嘗試內封閉,

String cell= "<pre>"+a +"<br/>"+ b+"</pre>"; 
+0

不幸的是它將它渲染爲:

aaa 
bbb
在瀏覽器中 – user2298581

相關問題