首页 > 技术文章 > java web前端发送请求的4种方式

YangGC 2018-05-10 20:23 原文

 

表单 action, 链接href,js 绑定按钮 ajax绑定标签

<h1>通过表单提交参数</h1>
        <form action="/day46_v1/ServletDemo01?method=addUser" method="post">
            用户名:<input type="text" name="username"/><button>提交</button>
        </form>
        <h1>通过链接提交参数</h1>
        <a href="/day46_v1/ServletDemo01?method=delUser&uid=003">删除</a>
        <h1>通过Ajax提交参数</h1>
        <input type="text" name="username"/><button onclick="fn()">发送请求</button>
        <h1>通过JS发送请求</h1>
        <button onclick="fm()">点击我向服务端发起请求</button>

 

推荐阅读