1. .html文件(邮件内容)
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td width="16%">#author#</td>
<td width="84%">#lastUpdate#</td>
</tr>
<tr>
<td> </td>
<td>#res#</td> //1.re变量,表示“留言内容” 2.在邮件里面,留言内容是不换行的?——re是SalesOrderComment.java的属性,留言的时候,也用了回车键,而且在.jsp页面里面显示的时候,re留言内容是换行的……只是在邮件里面,为什么它就没有换行?
</tr>
</table>
2. .java文件
final SalesOrderComment model;
//
static final SimpleDateFormat SDF = new SimpleDateFormat("MMM dd, yyyy"); public String build(String content, String serverName) throws Exception {
content = content
.replace("#uid#", account.getUsername())
.replace("#contact#", var.getLinkman())
.replace("#orderNo#", varSO.orderNo)
.replace("#ordId#", String.valueOf(varSO.ordId))
.replace("#orderDate#", SDF.format(varSO.orderDate))
.replace("#qty#", String.valueOf(varSO.qty))
.replace(
"#netAmount#",
var.getCurr().symbol
+ String.valueOf(varSO.netAmount))
.replace("#amount#",
var.getCurr().symbol + String.valueOf(varSO.amount))
.replace("#shipMethod#", varSO.shipMethod)
.replace("#realDeliDate#", SDF.format(varSO.realDeliDate))
.replace("#enHtml#", varSO.status.enHtml)
.replace("#author#", model.author)
.replace("#lastUpdate#", SDF.format(model.lastUpdate))
.replace("#res#", model.res)
.replace("#host#", serverName);
return content;
}
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td width="16%">#author#</td>
<td width="84%">#lastUpdate#</td>
</tr>
<tr>
<td> </td>
<td>#res#</td> //1.re变量,表示“留言内容” 2.在邮件里面,留言内容是不换行的?——re是SalesOrderComment.java的属性,留言的时候,也用了回车键,而且在.jsp页面里面显示的时候,re留言内容是换行的……只是在邮件里面,为什么它就没有换行?
</tr>
</table>
2. .java文件
final SalesOrderComment model;
//
static final SimpleDateFormat SDF = new SimpleDateFormat("MMM dd, yyyy"); public String build(String content, String serverName) throws Exception {
content = content
.replace("#uid#", account.getUsername())
.replace("#contact#", var.getLinkman())
.replace("#orderNo#", varSO.orderNo)
.replace("#ordId#", String.valueOf(varSO.ordId))
.replace("#orderDate#", SDF.format(varSO.orderDate))
.replace("#qty#", String.valueOf(varSO.qty))
.replace(
"#netAmount#",
var.getCurr().symbol
+ String.valueOf(varSO.netAmount))
.replace("#amount#",
var.getCurr().symbol + String.valueOf(varSO.amount))
.replace("#shipMethod#", varSO.shipMethod)
.replace("#realDeliDate#", SDF.format(varSO.realDeliDate))
.replace("#enHtml#", varSO.status.enHtml)
.replace("#author#", model.author)
.replace("#lastUpdate#", SDF.format(model.lastUpdate))
.replace("#res#", model.res)
.replace("#host#", serverName);
return content;
}
(这是之前别人的建议)
1.看下你写几个固定的文字上去,然后加入<br>,然后测试看是否自动换行,————自己添加的<br/>是换行的;
但#res#内部的数据始终不换行!<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td width="16%">#author#</td>
<td width="84%">#lastUpdate#</td>
</tr>
<tr>
<td> </td>
<td>#res# 1<br/>1<br/>1<br/></td> //#res#内部的数据始终不换行!
</tr>
</table>
2.若是有的话,则是其它样式造成的,例如 td是否有样式固定不允许换行————td让上所示,并没有什么其他的样式……
已经解决!要先用String.replace("\n","<br>");处理一下字符串
这个不应该是这样写的,你这个是为了解决问题而解决问题。
我觉得你要么在td里面自定义换行,就是不用用户输入的换行符,第二种就是 在客户输入的哪个地方,
用把br就转掉