jsp request实现注册表单界面

<%@ 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");//post方式设置编码类型
		String name=request.getParameter("uname");//从request取数据,通俗说就是从浏览器取数据
		//Integer.parseInt()方法将一个字符串转换成int型
		int age=Integer.parseInt(  request.getParameter("uage")  ) ;//int里只能是数字
		String pwd=request.getParameter("upwd");
		String[] hobbies=request.getParameterValues("uhobbies");
		%>
		注册成功,信息如下:<br/>
		姓名:<%=name %><br/>
		年龄:<%=age %>
		密码:<%=pwd %><br/>
		爱好:<br/>
		
		<%
			if(hobbies!=null){
				for(String hobby:hobbies){
					out.print(hobby+"&nbsp;");
				}
			}
		%>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_41648092/article/details/86557831
今日推荐