加入 _csrf 防范,提交数据需加csrf
<form action="/news/doAdd?_csrf=<%=csrf%>" method="POST">
用户名:<input type="text" name="username"/><br><br>
密 码:<input type="text"name="password" type="password"/>
<button type="submit">提交</button> </form>
路由:
控制器:
csrf配置全局变量,模板
在中间件里设置
引入中间件