<%@ 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>
<jsp:useBean id="user" scope="page" class="ch04.UserRegisterBean"></jsp:useBean>
<jsp:setProperty property="*" name="user"/>
注册成功:
<hr>
使用Bean属性方法:
<br>
<%response.setContentType("text/html; charset=UTF-8"); %>
<%request.setCharacterEncoding("UTF-8"); %>
用户名:<%=user.getUserName() %>
<br>
年龄:<%=user.getAge() %>
<br>
密码:<%=user.getPassword() %>
<br>
使用getProperty动作:
<br>
<jsp:getProperty property="userName" name="user"/>
<br>
部分代码如上,获取userName的时候如果输中文总是乱码