javaweb学习之路(1)request
2021-01-21 02:15
标签:input dcl 创建 访问 forward eclipse gets ips NPU
1.本次练习写一个简单的注册页面
准备工作:首先搭建好服务器tomcat环境,使用的编译软件是eclipse
2.在eclipse中创建一个web工程
3.在webContent文件夹下创建一个register.jsp文件chua
主要代码:在
的里面 form action="show.jsp"method="post">
用户名:input type="text" name="uname"/>br/>
密码:input type="password" name="upwd"/>br/>
年龄:input type="text" name="uage"/>br/>
爱好:
input type="checkbox" name="uhobbies" value = "唱跳"/>唱跳
input type="checkbox" name="uhobbies" value = "Rap"/>Rap
input type="checkbox" name="uhobbies" value = "篮球"/>篮球br/>
input type="submit" value="注册">
form>
4.在webContent文件夹下创建一个show.jsp文件
主要代码:还是在
标签里面
//设置编码
request.setCharacterEncoding("utf-8");
String name = request.getParameter("uname");
String pwd = request.getParameter("upwd");
int age = Integer.parseInt(request.getParameter("uage"));
String[] hobbies = request.getParameterValues("uhobbies");
%>
注册成功,信息如下:br/>
姓名:=name%>br/>
密码:=pwd%>br/>
年龄:=age%>br/>
爱好:br/>
if(hobbies!=null){
for(String hobby:hobbies){
out.print(hobby+" ");
}
}
%>
5.上机效果:
总结:request:请求对象;存储“客户端向服务端发送的请求信息”
javaweb学习之路(1)request
标签:input dcl 创建 访问 forward eclipse gets ips NPU
原文地址:https://www.cnblogs.com/ma1998/p/12897710.html
上一篇:org.springframework.web.bind.annotation不存在 site:blog.csdn.net(IDEA中运行springboot时报错)
下一篇:python学习-pandas