邮件中如何写html

本文介绍如何使用StringBuilder对象在Java中生成带有样式的HTML表单。通过append方法添加表单元素,并确保替换所有空格为 以避免信息丢失。示例代码展示了如何创建包含输入框和标签的复杂表单。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 StringBuilder stringBuilder = new StringBuilder();利用StringBuild对象

将写好样式的表单或者表格用append方法添加,最后用stringBuilder.toString()方法即可转为实际页面

注意将所有值的空格全部替换成" "否则,有空格的值无法读取完整信息。

 stringBuilder.append(
"<body style=\"background:#CEFFCE\">\n"+
        "<form>\n"+
            "<div style=\"text-align:right\">\n"+
                "<label  style=\"font-family:微软雅黑;font-size:13px\">Date Reported:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RPT_DTE")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Your Name:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RPT_NAM")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Your Department:</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RPT_DPT")).replace(" ", "&nbsp;")+"><br/>\n"+
            "</div>\n"+
        "</form>\n"+
        "<hr />\n"+
        "<p style=\"text-align:center;font-weight:bold\" >Transaction Details</p>\n"+
        "<hr />    \n"+
        "<form>\n"+
            "<div style=\"text-align:right\">\n"+
                "<label  style=\"font-family:微软雅黑;font-size:13px\">Transaction Reference:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("TRANS_REF")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Currency:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("CURRENCY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Transaction Amount(FCY):</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("AMOUNT_FCY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label  style=\"font-family:微软雅黑;font-size:13px\">Transaction Amount(LCY):</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("AMOUNT_LCY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Value Date of Transaction:</label><input type=\"text\"  style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("VALUE_DATE")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What bank are we are receiving the funds from?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("FRM_BAK")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What country are the funds coming from?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("FRM_CTY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What bank are we paying the funds to?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("PAY_BAK")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">What country are we paying the funds to?</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("PAY_CTY")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Name of the Remitter:</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("RMT_NAM")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Name of the Beneficiary:</label><input type=\"text\" style=\"width:400px;margin:3px 0px 3px 0px\" value="+((String)param.get("BFY_NAM")).replace(" ", "&nbsp;")+"><br/>\n"+
                "<label style=\"font-family:微软雅黑;font-size:13px\">Do you suspect that Money Laundering has already taken place?<label/>");
                 if(spcLdr){
                      stringBuilder.append(STYLE_CHECKED);
                 }else{
                     stringBuilder.append(STYLE_NOCHECKED);
                 }
                 stringBuilder.append("<label style=\"font-family:微软雅黑;font-size:13px\">Do you think that this transaction is money laundering or terrorist financing in action?<label/>");
                 if(spcFnc){
                     stringBuilder.append(STYLE_CHECKED);
                }else{
                    stringBuilder.append(STYLE_NOCHECKED);
                }
                 stringBuilder.append("<label style=\"font-family:微软雅黑;font-size:13px\">Are you asking for the consent ot the MLRO to undertake the transaction?<label/>");
                 if(spcUtk){
                    stringBuilder.append(STYLE_CHECKED);
                 }else{
                   stringBuilder.append(STYLE_NOCHECKED);
                 }
                 stringBuilder.append(
             "</div>\n"+
        "</form>\n"+
        "<hr />\n"+
        "<div style=\"text-align:right\">\n"+
            "<label  style=\"font-family:微软雅黑;font-size:13px\">Explain why are you Suspicious about this transaction?</label><br/>\n"+
            "<textarea  style=\"width:939px;height:100px;margin:3px 0px 3px 0px\">"+((String)param.get("RPT_DCP")).replace(" ", "&nbsp;")+"</textarea><br/>\n"+
        "</div>\n"+
        "<hr />\n"+
"</body>"
                 );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

menglixiazhiweizhi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值