jsp 笔记 关于数据交互
来源:互联网 发布:南京邮电大学网络攻防 编辑:程序博客网 时间:2024/06/05 18:56
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><form action="index.jsp" method="post"> 用户名: <input type="text" name="txtname" value="<%=request.getAttribute("name") %>"/> 密码: <input type="password" name="txtpwd"/> <input type="submit" value="提交"/> <br/> 爱好<input type="checkbox" name="hello" value="跑步"/> <input type="checkbox" name="hello" value="游泳"/> <input type="checkbox" name="hello" value="骑马"/></form></body></html>
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><%request.setCharacterEncoding("utf-8");String [] jihe=request.getParameterValues("hello"); String a=""; String b=""; String c="";if(jihe!=null){switch(jihe.length){case 1:a=jihe[0];break;case 2:a=jihe[0];b=jihe[1];break;case 3:a=jihe[0];b=jihe[1];c=jihe[2];break;}} String name = request.getParameter("txtname");System.out.println(name);String pwd = request.getParameter("txtpwd");if (name.equals("中文") && pwd.equals("1")) {//保存作用域的值request.setAttribute("name", name);//request.setAttribute("jihe", jihe); request.setAttribute("jihe0", a);request.setAttribute("jihe1",b);request.setAttribute("jihe2", c); //跳转request.getRequestDispatcher("/go.jsp").forward(request,response);}else{//保存值request.setAttribute("name", name);//request.getRequestDispatcher("/regit.jsp").forward(request,response);//重定义response.sendRedirect("/Day_02shili/regit.jsp");}if(jihe!=null){for(String item:jihe){out.print(item+" ");}}%>输入错误页面</body></html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body>欢迎你 <%=request.getAttribute("name") %> <%=request.getAttribute("jihe0") %><%=request.getAttribute("jihe1") %> <%=request.getAttribute("jihe2") %> </body></html>
0 0
- jsp 笔记 关于数据交互
- js jsp 数据交互
- JSP数据交互
- JSP数据交互
- JSP数据交互(一)
- jsp数据交互(二)
- JSP数据的交互
- JSP数据交互
- JSP数据交互
- jsp数据交互(I)
- jsp数据交互(II)
- Jsp数据交互
- jsp数据交互1
- jsp数据交互2
- jsp --- 数据交互
- jsp ----- 数据交互 继续
- JSP 数据交互
- JSP 数据交互(2)
- ARM新GPU架构Midgard
- CoordinatorLayout实现优雅的炫酷效果
- 错误:com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
- Android 百度SDK由3.3升级到4.3中间问题解决
- spring-boot1.5开发的war包如何部署到tomcat
- jsp 笔记 关于数据交互
- Oracle递归查询(目录结构查询)
- sizeof与offsetof有关的结构体详解
- Git起步
- spring事务在try catch时候的执行
- mac 下redis自启动设置
- VS 2015 + Qt 5.8 环境配置
- fork函数的使用
- bat批处理文件的编写语法