<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<style>
<!--
p.MsoNormal
{mso-style-parent:"";
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:"Times New Roman";
margin-left:0cm; margin-right:0cm; margin-top:0cm}
-->
</style>
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<link rel="File-List" href="in14_Logon_Role_files/filelist.xml">
<!--[if gte mso 9]>
<xml><o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml><![endif]-->
</head>
<body>
<p class="MsoNormal" align="center" style="text-align:center"><b>
<span style="font-size: 16.0pt; font-family: 宋体">如何建立一个带登陆页面及角色的Struts数据库应用程序</span></b></p>
<p class="MsoNormal"><b>
<span lang="EN-US" style="font-size:9.0pt;font-family:宋体"> </span></b></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><b><span lang="EN-US">[</span><span style="font-family: 宋体">目标</span><span lang="EN-US">]</span></b></p>
<p class="MsoNormal" style="text-indent: 21.0pt"><span style="font-family: 宋体">
本例的目标是实现一个用户登陆应用程序。用</span><span lang="EN-US">SQL</span><span style="font-family: 宋体"> </span><span lang="EN-US">Server
2000</span><span style="font-family: 宋体">数据库保存用户信息。实现用户登陆页面、用户登陆验证、登陆检查标签等功能。</span></p>
<p class="MsoNormal"><span style="font-family: 宋体">定义一个名为“</span><span lang="EN-US">users</span><span style="font-family: 宋体">”表的字段:</span></p>
<p class="MsoNormal" style="text-indent: 21.0pt"><span lang="EN-US"><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_s1025" type="#_x0000_t75" style='width:270.75pt;
height:98.25pt'>
<v:imagedata src="in14_Logon_Role_files/image001.png" o:title=""/>
</v:shape><![endif]--><![if !vml]><img border=0 width=361 height=131
src="in14_Logon_Role_files/image002.jpg" v:shapes="_x0000_s1025"><![endif]></span></p>
<p class="MsoNormal" style="text-indent: 21.0pt"><span style="font-family: 宋体">
录入一些测试数据:</span></p>
<p class="MsoNormal" style="text-indent: 21.0pt"><span lang="EN-US"><!--[if gte vml 1]><v:shape
id="_x0000_s1026" type="#_x0000_t75" style='width:265.5pt;height:223.5pt'>
<v:imagedata src="in14_Logon_Role_files/image003.png" o:title=""/>
</v:shape><![endif]--><![if !vml]><img border=0 width=354 height=298
src="in14_Logon_Role_files/image004.jpg" v:shapes="_x0000_s1026"><![endif]></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span><span style="font-family: 宋体">
例如上面的数据,一个用户可能有一个角色,也可以有多个角色。对于多个角色,可以用多条记录来表示,一条记录表示一个角色,也可以用一条记录表示多个角色,每个角色用“</span><span lang="EN-US">;</span><span style="font-family: 宋体">”来分开。</span></p>
<p class="MsoNormal"><b><span lang="EN-US">[</span><span style="font-family: 宋体">效果</span><span lang="EN-US">]</span></b></p>
<p class="MsoNormal"><span style="font-family: 宋体">欢迎页面:<br>
</span><span lang="EN-US"><!--[if gte vml 1]><v:shape
id="_x0000_s1027" type="#_x0000_t75" style='width:467.25pt;height:333.75pt'>
<v:imagedata src="in14_Logon_Role_files/image005.png" o:title=""/>
</v:shape><![endif]--><![if !vml]><img border=0 width=623 height=445
src="in14_Logon_Role_files/image006.jpg" v:shapes="_x0000_s1027"><![endif]></span></p>
<p class="MsoNormal"><span style="font-family: 宋体">登陆页面:</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if gte vml 1]><v:shape
id="_x0000_s1028" type="#_x0000_t75" style='width:467.25pt;height:333pt'>
<v:imagedata src="in14_Logon_Role_files/image007.png" o:title=""/>
</v:shape><![endif]--><![if !vml]><img border=0 width=623 height=444
src="in14_Logon_Role_files/image008.jpg" v:shapes="_x0000_s1028"><![endif]></span></p>
<p class="MsoNormal"><span style="font-family: 宋体">登陆完成后主菜单页面:</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if gte vml 1]><v:shape
id="_x0000_s1029" type="#_x0000_t75" style='width:467.25pt;height:333.75pt'>
<v:imagedata src="in14_Logon_Role_files/image009.png" o:title=""/>
</v:shape><![endif]--><![if !vml]><img border=0 width=623 height=445
src="in14_Logon_Role_files/image010.jpg" v:shapes="_x0000_s1029"><![endif]></span></p>
<p class="MsoNormal" style="text-indent: 21.1pt"><b>
<span style="font-family:黑体">如果不登陆而是直接运行</span><span style="font-family: 黑体">主菜单页面用户查询页面,将会自动先转到用户登陆页面,这里不再给出演示效果图。</span></b></p>
<p class="MsoNormal"><b><span lang="EN-US"> </span></b></p>
<p class="MsoNormal"><b><span lang="EN-US"> </span></b></p>
<p class="MsoNormal"><b><span lang="EN-US"> [</span><span style="font-family: 宋体">背景知识</span><span lang="EN-US">]</span></b></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:14.0pt">[</span><span style="font-size: 14.0pt; font-family: 宋体">步骤</span><span lang="EN-US" style="font-size:14.0pt">]</span></b></p>
<p class="MsoNormal" style="text-indent: 17.7pt"><b>
<span style="font-size: 9.0pt; font-family: 宋体">本例与《如何实现Struts
数据库应用程序》中的步骤相比,除了在建立新项目时一个选择“带登陆页面及角色的Struts数据库应用模板”而另一个选择“空的Struts数据库应用模板”,以及在JSP页面中需要检查用户是否已登陆的地方加一个标签“<app:checkLogon
role=</span><span style="font-size: 9.0pt">“</span><span style="font-size: 9.0pt; font-family: 宋体">system</span><span style="font-size: 9.0pt">”</span><span style="font-size: 9.0pt; font-family: 宋体">/>”之外,其它步骤完全一样,这样相同的步骤详情见《如何实现Struts
数据库应用程序》。</span></b></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">1</span><span style="font-family: 宋体">、打开</span><span lang="EN-US">Visual
Struts</span><span style="font-family: 宋体">开发环境:</span></p>
<p class="MsoNormal" style="text-indent: 26.25pt"><span style="font-family: 宋体">
从桌面</span><span lang="EN-US">JavaWebStudio</span><span style="font-family: 宋体">快揵或</span><span lang="EN-US">BIN</span><span style="font-family: 宋体">目录下的</span><span lang="EN-US">JavaWebStudio.exe</span><span style="font-family: 宋体">文件启动</span><span lang="EN-US">JavaWebStudio</span><span style="font-family: 宋体">的</span><span lang="EN-US">Visual
Struts</span><span style="font-family: 宋体">开发环境。</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">2</span><span style="font-family: 宋体">、建立一个“空的</span><span lang="EN-US">Struts</span><span style="font-family: 宋体">数据库应用模板”应用程序:</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span>
<span style="font-family: 宋体">选择菜单“文件”</span><span lang="EN-US">—</span><span style="font-famil
- 1
- 2
- 3
前往页