0

我是 Web 开发的新手,我的问题是当我单击“我的链接”时,由于 id 中有大量变量,它给了我“错误请求”。-我应该如何更改代码以发送 POST 请求?- 有更好的解决方案来处理这种情况吗?

谢谢

<!DOCTYPE html "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String var3 = request.getParameter("var3");
    String var4 = request.getParameter("var4");
    String var5 = request.getParameter("var5");
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>title</title>
        <link rel="stylesheet" href="../style.css"/>
        <link rel="stylesheet" href="../common/css/cupertino/jquery-ui-1.8.4.custom.css" type="text/css" media="screen" />
        <script type="text/javascript" language="javascript" src="../common/scripts/jquery/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" language="javascript" src="../common/scripts/jquery/jquery-ui-1.8.4.custom.min.js"></script>
        <script type="text/javascript" language="javascript" src="../common/scripts/jquery/jquery.dialogextend.js"></script>
        <script type="text/javascript" language="javascript" src="../common/scripts/troubleshoot.js"></script>
        <script type="text/javascript">
            var selectedVariables = function(event, ui) {
                var var1 = $('#tbodyvar1 .ui-selected');
                if (var1.size() <= 0) {
                    $('#var1Menu').addClass('var2');
                    $('#novar1Menu').removeClass('var2');
                } else {
                    var ids = '';
                    var1.each(function () {
                        if (ids.length > 0) {
                            ids += ',';
                        }
                        ids += $(this).find("td").eq(0).html();;
                    });
                    $('#var1Menu').removeClass('var2');
                    $('#novar1Menu').addClass('var2');
                    $('#totalvar1').html(var1.size());
                    $('#somelink').attr('href', 'anotherJSP.jsp?action=init&var3=<%=var3%>&var4=<%=var4%>&var5=<%=var5%>&ids=' + ids);
                }
            };
            $(document).ready(function() {
                $('.popup').click(function(e) {
                    e.preventDefault();
                    var $this = $(this);
                    var horizontalPadding = 30;
                    var verticalPadding = 30;
                    $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
                        title: ($this.attr('title')) ? $this.attr('title') : '',
                        autoOpen: true,
                        width: 560,
                        height: 600,
                        modal: false,
                        resizable: false,
                        autoResize: true,
                        overlay: {
                            opacity: 0.5,
                            background: "black"
                        }
                    }).dialogExtend({
                        "maximize" : true,
                        "icons" : {
                            "maximize" : "ui-icon-circle-plus"
                        },
                        "events" : {
                            "maximize" : function(evt, dlg){
                                window.open(this.src);
                                $(this).dialog("close");
                            }
                        }
                    }).width(560 - horizontalPadding).height(600 - verticalPadding);
                });
                $('.popup2').click(function(e) {
                    e.preventDefault();
                    var $this = $(this);
                    var horizontalPadding = 30;
                    var verticalPadding = 30;
                    $('<iframe id="externalSite" class="externalSite" src="' + this.href + '&hideHeader=true" />').dialog({
                        title: ($this.attr('title')) ? $this.attr('title') : '',
                        autoOpen: true,
                        width: 800,
                        height: 600,
                        modal: false,
                        resizable: false,
                        autoResize: true,
                        overlay: {
                            opacity: 0.5,
                            background: "black"
                        }
                    }).width(800 - horizontalPadding).height(600 - verticalPadding);
                });
                $("#tbodyvar1").selectable({
                    filter: "tr:not(.ui-notselectable)",
                    cancel: 'a',
                    stop: selectedVariables
                });
                $("#tbodyvar6").selectable({
                    filter: "tr:not(.ui-notselectable)",
                    cancel: 'a',
                    stop: selectedVariables2
                });

                $("div#info").hide();
            });
        </script>
    </head>
    <body>
        <h1>h1</h1>
        <div id="var1Menu" class="var2" style="padding:10px 0 0 10px"> 
            <ul>
                <li>
                    <a id="somelink" href="#" class="popup2" target="_blank">my link</a>
                </li>
            </ul>
        </div>  
    </body>
</html>
4

0 回答 0