后台获得数据
2020-04-05 18:18
85 查看
后台获得数据
1 <body> 2 3 <form action = "do_post.jsp" method = "post"> 4 5 用户名:<input type = "text" id = "" name = "user"> 6 <br> 7 密码: <input type = "password" id = "" name = "pass"> 8 <br> 9 性别: 10 <br> 11 男<input type = "radio" id = "" name = "sex" value = "nan"> 12 女<input type = "radio" id = "" name = "sex" value = "nv"> 13 <br> 14 个人说明: 15 <br> 16 <textarea rows="4" cols="35" id = "" name = "text"></textarea> 17 <br> 18 <input type = "submit" value = "提交"> 19 </form> 20 21 </body>
对于这些输入或单选都可以使用普遍输出:
1 <body> 2 <% 3 String user = request.getParameter("user"); 4 request.setAttribute("user", user); 5 6 String pass = request.getParameter("pass"); 7 request.setAttribute("pass", pass); 8 9 String sex = request.getParameter("sex"); 10 request.setAttribute("sex", sex); 11 12 String text = request.getParameter("text"); 13 request.setAttribute("text", text); 14 %> 15 16 <p>${user }</p> 17 <p>${pass }</p> 18 <p>${sex }</p> 19 <p>${text }</p> 20 </body>
而多选框因为多选,输出的是一个数组,所以:
1 <body> 2 爱好: 3 <br> 4 骑行<input type = "checkbox" id = "" name = "favorite" value = "qixing"> 5 爬山<input type = "checkbox" id = "" name = "favorite" value = "pashan"> 6 游泳<input type = "checkbox" id = "" name = "favorite" value = "youyong"> 7 蹦极<input type = "checkbox" id = "" name = "favorite" value = "bengji"> 8 </body>
1 <body> 2 String favorite[] = request.getParameterValues("favorite"); 3 request.setAttribute("favorite", favorite); 4 <% 5 for(String a : favorite){ 6 %> 7 <%=a %> 8 <%}%> 9 </body>
补充:
req.setCharacterEncoding("utf-8"); 改变编码格式
posted on 2017-12-16 13:43 沈汉学 阅读(...) 评论(...) 编辑 收藏
转载于:https://www.cnblogs.com/shenhx666/p/8046051.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Extjs4学习笔记(五)------checkboxgroup插件从后台获得数据,一键全选
- 原生js,jquery通过ajax获得后台json数据动态新增页面元素
- jQuery通过ajax获得后台json数据给form表单赋值
- 用form-data格式传数据,后台servlet的httpservletrequest无法获得值
- Struts2+JQuery+JSON实现异步交互,包括从后台获得单个值、对象、List和Map数据并从前台的表达中获取值
- ext combo 防搜索功能,从后台获得数据
- highcharts 渲染到ext4.0组件以及动态获得后台图表数据
- highcharts动态获得后台数据数据
- dhtmlxtree 后台查询数据获得id显示在tree中
- highcharts 渲染到ext4.0组件以及动态获得后台图表数据
- C#后台获得前台JS数据值
- Vue请求SSM的后台接口获得要导出Excel的数据
- Form提交中文数据时,后台获得出现乱码问题解决。
- $post传输如何获得后台数据
- 后台获得UltraWebGrid在前台修改过数据的单元格
- easyui 中的 form 提交 后获得 后台 的 json数据 与 jquery .ajax的不同之处
- ExtJS4.2学习(六)表格分页与通过后台脚本获得分页数据 推荐
- 从后台获得数据,展现在ftl文件中
- 后台获得前台数据为null,""
- ExtJS4.2学习(六)表格分页与通过后台脚本获得分页数据