一只超 2020-01-12 16:31 采纳率: 0%
浏览 1304

JS换行保存后,不显示换行,显示的却是字符<br>

图片说明
缺陷内容保存后可以换行显示,处理结果就不可以,就显示

function getAdd() {
    var w=$(window).width();
    var h=$(window).height();
    $('#dd').dialog({
        title: '添加缺陷记录',
        width: w * .6,
        height: h - 136,
        closed: false,
        cache: false,
        href: 'dia/log/defect-record/get-add.html?module_id=' + module_id + '&station_info=' + station_info,
        modal: true,
        buttons: [{
            text: '保存',
            iconCls: "easy-icon-save",
            handler: function () {
                var shift = $("#reportShift").combobox("getValue");
                if(shift == -1 || shift == ""){
                    $.messager.alert('操作', '请重新核对缺陷上报日期以及所选班次');
                    return false;
                }
                checkStation("station");//检测是否选择或输入
                var defectLevel = $('#defectLevel').combobox('getValue');
                if (defectLevel == 0 || defectLevel == 1) {
                    var planTime = $('#planProTime').datebox('getValue');
                    if (planTime == null || planTime == '') {
                        $.messager.alert("修改", "计划处理时间不能为空!", "error");
                        return;
                    }
                }
                var data = $("#defect-add-form").serialize();
                // var content = $('#content').val().replace(/\n/g,"<br/>");
                $.ajax({
                    url: "dia/log/defect-record/insert.do?module_id=" + module_id + '&proResult=' + $('#proResult').val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '),
                    type : "post",
                    dataType : "json",
                    data : data,
                    success : function(request) {
                        if(request.success){
                            query();
                        }
                        $.messager.show({
                            title: '操作提示',
                            msg: request.msg,
                            timeout: 2000,
                            sshowType: 'slide'
                        });
                    }
                });

                $("#dd").dialog({
                    closed: true
                });
            }
        }, {
            text: '关闭',
            iconCls: "easy-icon-cancel",
            handler: function () {
                $("#dd").dialog({
                    closed: true
                });
            }
        }],
        //用于图形化,窗口打开完成后,给厂站赋值
        onLoad: function () {
            var indexDevId = $("#indexDevId").val();
            $('#station').combobox('setValue', indexDevId);
        }
    });
}

这是JSP代码

            <tr>
                <td class="td-inputtitle" style="text-align: center">处理结果</td>
                <td class="td-input" colspan="5" >
                    <c:forEach var="item" items="${historyProcess }">
                        <c:if test="${item.proResult!=null && item.proResult!='' }">
                            <div class="history_process">
                                <div class="user_info">${item.userName }<br/>${item.time }</div>
                                <div class="content" >${fn:replace(item.proResult,vEnter,'<br>') } </div>
                                <div class="clearfix"></div>
                            </div>
                        </c:if>
                    </c:forEach>
                    <textarea type="text" rows="6" name="proResult" id="proResult"
                              style="width:95%;"> ${currProcess.proResult } </textarea>
                </td>
            </tr>
  • 写回答

1条回答 默认 最新

  • 崽崽的谷雨 2020-01-13 08:50
    关注

    你渲染的时候可以用innerHtml试试,把html字符串转成html

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?