JSP | 基础 | 在同一表单中提交两个不同的action

通过与跟JS配合使用实现需求

<head>
    <title>Chat Room</title>
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="js/chat.js"></script>
    <link rel="stylesheet" href="css/chat.css"/>
    <Script Language="JavaScript"> 
        function modify() 
        { 
            document.chatform.action="chat"; 
            document.chatform.submit(); 
        } 
         
        function exit() 
        {
            document.chatform.action="outlogin.jsp";
            document.chatform.submit();
        }
        
    </Script> 
</head>

<body>
  
        <form name="chatform" action="chat" method="post">
            <table cellpadding="0" cellspacing="0">
<tr> <td class="pl"> <input id="Button1" type="button" value="Send" class="btn" onClick="modify()"/> <input id="Button2" type="button" value="Exit" class="btn" onClick="exit()"/> <input id="Button4" style="display:none" type="button" value="Hide" class="btn"/> </td> </tr> </table> </form> </body>

扩展:

  提交form的时候,附带默认参数。

需要在表单里添加一个隐藏的input

<input type="hidden" name="args" value="888">

学习博客:

https://blog.csdn.net/LF_Software_Studio/article/details/7370007

猜你喜欢

转载自www.cnblogs.com/jj81/p/9783294.html