1. 程式人生 > >form表單提交 method為get對於action的影響

form表單提交 method為get對於action的影響

   <form action="BaseServlet?method=addStu" method="get">
        <input type="text" name="username">
        <input type="submit" value="提交">
    </form>

如果直接點選提交

http://localhost:8080/WebProject/BaseServlet?username=

此時action上的?method=addStu被過濾掉

解決:

1、在form表單新增一個隱藏欄位 method

    <form action="BaseServlet" method="get">
        <input type="hidden" name="method" value="addStu">
        <input type="text" name="username">
        <input type="submit" value="提交">
    </form>

2、method使用post