实验六 表单开发Word文档格式.docx

上传人:b****1 文档编号:14682142 上传时间:2022-10-23 格式:DOCX 页数:13 大小:49.66KB
下载 相关 举报
实验六 表单开发Word文档格式.docx_第1页
第1页 / 共13页
实验六 表单开发Word文档格式.docx_第2页
第2页 / 共13页
实验六 表单开发Word文档格式.docx_第3页
第3页 / 共13页
实验六 表单开发Word文档格式.docx_第4页
第4页 / 共13页
实验六 表单开发Word文档格式.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

实验六 表单开发Word文档格式.docx

《实验六 表单开发Word文档格式.docx》由会员分享,可在线阅读,更多相关《实验六 表单开发Word文档格式.docx(13页珍藏版)》请在冰豆网上搜索。

实验六 表单开发Word文档格式.docx

Login.html<

/title>

/head>

body>

form 

name="

Login"

action="

Forward.jsp"

method="

post"

>

table>

tr>

td>

用户类型<

/td>

select 

name 

="

User"

option 

value="

Student"

学生<

/option>

Teacher"

老师<

/select>

/tr>

用户名<

input 

Username"

type="

text"

size="

20"

用户密码<

Password"

password"

submit"

提交"

/table>

/form>

/body>

/html>

-Forward.jsp:

根据用户类型,进行任务转发。

如果是教师类型,把任务转发给Teacher.jsp;

如果是学生类型,把任务转发给Student.jsp

%!

Stringdirection="

"

;

%>

%

request.setCharacterEncoding("

gbk"

);

StringkindOfUser=request.getParameter("

Stringname=request.getParameter("

Stringpassword=request.getParameter("

if(name==null||name.equals("

)||password==null||password.equals("

)){

direction= 

LoginFails.jsp"

}

else{

if(kindOfUser.equals("

 

Student.jsp"

Teacher.jsp"

jsp:

forward 

page="

%=direction%>

/jsp:

forward>

-Teacher.jsp:

如果用户名和密码都等于TEACHER,同时输出“登录成功”,否则页面返回到Login.html

%@ 

page 

language="

java"

import="

java.util.*"

pageEncoding="

Stringpath=request.getContextPath();

StringbasePath=request.getScheme()+"

:

//"

+request.getServerName()+"

+request.getServerPort()+path+"

/"

if(name.equals("

)&

&

password.equals("

out.println("

登录成功"

response.sendRedirect("

Login.html"

Teacher<

-Student.jsp:

输出:

您输入的用户名是***。

您输入的用户名是"

+name);

Student<

*2、附加:

表单填写错误判断

尝试改进以上内容,在Forward.jsp中增加判断:

若用户名或密码为null或为空,则返回到Login.html重新登录,并在登录页面的表单上方以红色字体显示:

“用户名或密码不能为空!

”。

写了一个LoginFails.jsp文件,通过以下关键字段:

和<

实现要需要的功能

一.Forward.jsp

request.setCharacterEncoding("

base 

href="

%=basePath%>

MyJSP'

Forward.jsp'

startingpage<

二.LoginFails

LoginFails<

body 

p>

font 

color="

#FF0000"

用户名或密码不能为空!

/font>

/p>

include 

include>

运行结果:

*3、附加:

用户注册功能

尝试完成用户注册功能,用户信息包括用户登陆名、密码、真实姓名、性别、出生年月、籍贯、Email、联系电话、联系地址、QQ号,要求对注册的信息进行有效性判断,并显示在页面。

Register.jsp

//判断是否是合格的Email格式

boolean 

isEmail(StringEmail){

flag= 

true;

int 

locationDot=Email.indexOf("

."

locationAt=Email.indexOf("

@"

//.和 

@中至少一个不存在

if(locationDot<

0||location

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 小学教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1