Home  >  Q&A  >  body text

java - There is a very strange problem when using <%= %> to obtain data on a .jsp page

Jump to a jsp page using <%=%>When getting data into the form, the console reports an error when jumping to the page: Invalid or unexpected token, the size field in the database It's text. I tried it. If there is newline data in the database, an error will be reported when jumping. If all the data is displayed in one line, the page will jump. Why is this? Please help me to answer

The following is the code:

//跳转到编辑页面 
         function editPartyActive(active_id,active_name,active_digest,active_url){
                 //var row = $('#datagrid_active').datagrid('getData').rows[index];
                 
                console.log("1111");
                console.log(active_id);
                var url = "/gxawebsite/partyactive.do?method=editPartyActivePage&active_id="+active_id+"&active_name="+active_name+"&active_digest="+active_digest+"&active_url="+active_url;  
                var tab = $("#data-tabs").tabs("getSelected"); //已经被选中的选项卡
                tab.panel('refresh', url); //重新加载一个url,来替换原来的url
            
            }

    //在datagrid里面增加一个操作的单元格,调用上面的方法跳转页面
        function operation(value, row, index) {
            
            return "<button  class='btn btn-danger' href='javascript:void(0);' onclick='delActive("
                    + row.active_id
                    + ")'>删除</button>&nbsp;&nbsp;<button class='btn btn-success'  id='editPartyActive'  href='javascript:void(0);' onclick='editPartyActive("+row.active_id+",&quot;"+row.active_name+"&quot;,&quot;"+row.active_digest+"&quot;,&quot;"+row.active_url+"&quot;)'>更新</button>";
                
        }

<!-- datagrid页面,数据已经展示在里面  -->
    <p class="easyui-layout" data-options="fit:true">
        <p data-options="region:'center',title:'党建活动'">
            <table id="datagrid_active" class="easyui-datagrid"
                data-options="fit:true,fitColumns:true,pagination:true,pageSize:10,toolbar:'#partyactive_tb'">
                <thead>
                    <tr>
                        <th data-options="field:'ck',width:80,checkbox:true"></th>
                        <th data-options="field:'active_id',width:40">活动编号</th>
                        <th data-options="field:'active_name',width:80">活动名称</th>
                        <th data-options="field:'active_digest' ,width:180 ">活动简介</th>
                        
                        <th field="active_url" data-options="width:80,formatter:imgOperation" >活动图片</th>
                        <th data-options="field:'state',width:80">审核状态</th>
                        <th data-options="field:'operation',formatter:operation,width:80">操作</th>
                    </tr>
                </thead>
                <tbody >
                    <tr>
                    </tr>
                </tbody>

            </table>
        </p>
    </p>


    <!-- 跳转后的页面,获取数据 -->
<body>
<%

request.setCharacterEncoding("utf-8");
String active_id = request.getParameter("active_id");

String active_name = new String(request.getParameter("active_name").getBytes("iso-8859-1"),"utf-8");
String active_digest = new String(request.getParameter("active_digest").getBytes("iso-8859-1"), "utf-8");

String active_url = new String(request.getParameter("active_url").getBytes("iso-8859-1"), "utf-8");
%>



<script type="text/javascript">
    /* function time(){
        
        setInterval(function() {
            var time = new Date();
            //console.log(time);
            // 程序计时的月从0开始取值后+1
            var m = time.getMonth() + 1;
            var t = time.getFullYear() + "-" + m + "-"
                    + time.getDate() + " "
                    + time.getHours() + ":"
                    + time.getMinutes() + ":"
                    + time.getSeconds();
                
                    $("#addActiveDate").val(t);
        }, 1000);
    }; */
    
    $(function(){
        
        
        
        //返回新闻列表
        $("#returnPartyActive").click(function(){
            var url = "${pageContext.request.contextPath}/partyactive.do?method=getPartyActive";
            var tab = $("#data-tabs").tabs("getSelected"); //已经被选中的选项卡
            tab.panel('refresh', url); //重现加载一个url,来替换原来的url
        });
    
        
        
        // 更新的操作 ---> form表单
        $('#editActiveForm').form({
            url:"${pageContext.request.contextPath}/partyactive.do?method=editPartyActive",
             onSubmit: function(){
                var str = /^$/;
                var active_name = $('#active_name').val();
                var active_digest = $('#active_digest').val();
                var active_url = $('#active_url').val();
                console.log(str.test(active_name));
                if(str.test(active_name) ||str.test(active_digest) || str.test(active_url)){
                    layer.tips("有内容为空不能提交!","#addLearnConfirm");
                    return false; 
                    
                } 
            },   
            success:function(data){   
                layer.msg('更新成功,页面即将跳转!', {icon: 1});
                setTimeout(function (){
                    var url = "${pageContext.request.contextPath}/partyactive.do?method=getPartyActive";
                    var tab = $("#data-tabs").tabs("getSelected"); //已经被选中的选项卡
                    tab.panel('refresh', url); //重现加载一个url,来替换原来的url
                    
                },2000)
                
            },
            onLoadError:function(){
                layer.msg('提交出错!', {icon: 5});
            }
            
        });
        
    
    })
</script>

    

    <p class="easyui-layout" data-options="fit:true"  style="overflow:auto;">
    <p data-options="region:'center',title:'修改活动'">
    <p id="party_active_tb" >
        <button class="btn btn-primary" data-options="iconCls:plain:true" id="returnPartyActive">返回列表</button>
    </p>
    <br>
    <p class="addPartyActive" style="margin-left:20px">
        <form id="editActiveForm" style="width:70%" method="post" action="" enctype ="multipart/form-data"  target="iframe_display">
                <p class="form-group">
                <label style="font-size:16px">活动编号:</label>
                <input type="text" class="form-control" value="<%=active_id %>" id="editActiveId" name="active_id" readonly >
            </p>        
            <p class="form-group">
                <label style="font-size:16px">活动标题:</label>
                <input type="text" class="form-control" value="<%=active_name %>"   id="active_name" name="active_name" placeholder="请输入标题">
            </p>
            <!-- <p class="form-group">
                <label style="font-size:16px">当前时间:</label>
                <input type="text" class="form-control"   id="editActiveDate" name="active_date" readonly>
            </p> -->
            
            <p class="form-group">
                <label style="font-size:16px">活动介绍:</label>
                <textarea rows="10" cols="50"  class="form-control" id="active_digest" name="active_digest" placeholder="请输入内容"> <%= active_digest %></textarea>
                <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
            </p>
            <p class="form-group">
                <label style="font-size:16px">图片:</label>
                
                <p><img src="${pageContext.request.contextPath}/img/<%=active_url %>" /></p>
                
                 <label style="font-size:16px">图片上传:</label>
                 <input type="file" class="form-control" id="active_url" value="<%= active_url%>"  name="active_url" placeholder="请上传图片">
 
                 
             </p>
            <p class="form-group"  style="display:none">
                <label style="font-size:16px">状态:</label>
                <input  type="text" class="form-control" id="addActiveState" name="state" value="未审核" readonly="readonly">
            </p>
            <!-- 注脚 -->
        <p class="modal-footer">
            <button type="submit" class="btn btn-default" id="addLearnConfirm" >确定</button>
            <button type="button" class="btn btn-primary" id="addLearnCancel">取消</button>
        </p>
            
        </form>
    </p>
    
    
</p>
</p>
        
    

</body>

代言代言2709 days ago1209

reply all(1)I'll reply

  • 学习ing

    学习ing2017-06-12 09:21:19

    It has nothing to do with jsp. . .

    This is a JS error.

    reply
    0
  • Cancelreply