bootstrap之模态框中表单无法提交

模态框中表单post提交时总会报403错误,get提交确可以,但是会出现乱码。查了许多资料,最终解决了,记录下来。

模态框post提交解决方案:

如果直接使用表单提交,就使用隐藏域保存token的值,和表单一起提交。
<span style="font-size:18px;"><input type="hidden" name="token" value="${token}"/></span>

如果是 Ajax 提交,那么可以在提交时将 Token 一起提交:
$.post('url','{'token':token}',function (data) { ......  });

这样提交表单就不会报403错误了,主要就是安全框架阻止了访问,必须验证token才可以访问。
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用Bootstrap模态框建立用户注册表单,可以按照以下步骤: 1. 在HTML文件引入Bootstrap的CSS和JS库文件。 2. 创建一个按钮,用于打开模态框: ``` <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#registerModal">注册</button> ``` 其,data-toggle="modal"表示点击按钮时打开模态框,data-target="#registerModal"表示模态框的ID为registerModal。 3. 创建一个模态框: ``` <div class="modal fade" id="registerModal" tabindex="-1" role="dialog" aria-labelledby="registerModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="registerModalLabel">用户注册</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form> <div class="form-group"> <label for="username">用户名</label> <input type="text" class="form-control" id="username" placeholder="请输入用户名"> </div> <div class="form-group"> <label for="email">邮箱</label> <input type="email" class="form-control" id="email" placeholder="请输入邮箱"> </div> <div class="form-group"> <label for="password">密码</label> <input type="password" class="form-control" id="password" placeholder="请输入密码"> </div> <button type="submit" class="btn btn-primary">注册</button> </form> </div> </div> </div> </div> ``` 其,modal-header部分为模态框的标题和关闭按钮,modal-body部分包含了用户注册表单,包括用户名、邮箱和密码,最后有一个注册按钮。 4. 使用JavaScript代码来处理用户提交注册表单的逻辑,例如验证表单数据、向后端发送请求等。 以上就是使用Bootstrap模态框建立用户注册表单的步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值