2016-09-30 56 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