您的位置:首页 > Web前端 > JavaScript

一个jsp的注册界面

2015-08-14 09:40 706 查看
index.jsp界面代码

[html] view
plaincopy

<%@ page language="java" contentType="text/html" import="java.util.*" pageEncoding="utf-8"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<title>用户注册页面</title>

</head>

<body>

用户注册信息:<br><hr>

<form action="register.jsp" method="get">

<table>

<tr>

<td>姓名:<input name="userName" type="text"></td>

</tr>

<tr>

<td>密码:<input name="password" type="text"></td>

</tr>

<tr>

<td>年龄:<input name="age" type="text"></td>

</tr>

<tr>

<td><input name="submit" type="submit" value="提交"></td>

</tr>

</table>

</form>

<hr>

</body>

</html>

register.jsp界面代码

[html] view
plaincopy

<%@ page language="java" contentType="text/html" import="java.util.*" pageEncoding="utf-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<jsp:useBean id="user" scope="page" class="info.RegisterBean"></jsp:useBean>

<jsp:setProperty property="*" name="user"/>

注册成功:<br><hr>

使用Bean属性方法:

<br>

用户名:<%=user.getUserName() %>

<br>

密 码:<%=user.getPassword() %>

<br>

年 龄:<%=user.getAge() %>

<br><hr>

使用getPorperty()方法:

<br>

用户名:<jsp:getProperty property="userName" name="user"/>

<br>

密 码:<jsp:getProperty property="password" name="user"/>

<br>

年 龄:<jsp:getProperty property="age" name="user"/>

<br><hr>

使用Jstl标签:

<br>

用户名:<c:out value="${user.userName}"></c:out>

<br>

密 码:<c:out value="${user.password}"></c:out>

<br>

年 龄:<c:out value="${user.age}"></c:out>

<br>

<hr>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: