选择显示字体大小

java:struts入门初步知识

1.如何安装struts
  首先到http://jakarta.apache.org/struts下载struts,建议使用release版,现在最高版本为1.2.6,有多种os版本(windows,linus...),下载后解压开来,可以看到这个目录:lib和webapps,webapps下有一些war文件。 假设你的tomcat装在c:\tomcat下,则将那些war文件拷贝到c:\tomcat\webapps,重新启动tomcat即可。打开浏览器,在地址栏中输入:http://localhost:8080/struts-example/index.jsp,若能见到“powered by struts”的深蓝色图标,即说明成功了。这是struts自带的一个例子,附有详细的说明文档,可以做为初学者的入门教程。另外,struts还提供了一系统实用对象:xml处理、通过java reflection apis自动处理javabeans属性、国际化的提示和消息等

2.练习做一个实例
  一个用户注册系统,用户通过网页输入相关信息:注册id号,密码,email,若注册成功,则返回成功提示信息,反之出现注册失败提示信息。 

  项目建立:
  正式开发前,需要在tocmat(我的tomcat装在c:\tomcat)中建立此项目。比较快的一种建立方式为:在c:\tomcat\webapps下新建目录test,再将c:\tomcat\webapps\struts-example下的web-inf目录拷贝到test目录下,然后将test\web-inf下的src和classes目录清空,以及struts-config.xml文件中内容清空即可。这样,我们需要的struts类包及相关的配置文件就都齐了。
  开发时,将jsp文件放在test目录下,java原文件放在test\web-inf\src下,编译后的类文件放在test\web-inf\classes下。

  注册页面:reguser.jsp

<&#37;@ page contenttype="text/html;charset=utf-8" language="java"
&#37;>

<&#37;@ taglib uri="/web-inf/struts-bean.tld" prefix="bean"
&#37;>

<&#37;@ taglib uri="/web-inf/struts-html.tld" prefix="html"
&#37;>

<html:html locale="true">

<head>

<title>reguser</title>

<html:base/>

</head>

<body bgcolor="white">

<html:errors/>

<html:form action="/reguseraction" focus="logname">


<table border="0" width="100&#37;">

<tr>

<th align="right">

logname:

</th>

<td align="left">

<html:text property="logname" size="20" maxlength="20"/>


</td>

</tr>

<tr>

<th align="right">

password:

</th>

<td align="left">

<html:password property="password" size="20" maxlength="20"/>


</td>

</tr>

<tr>

<th align="right">

e-mail:

</th>

<td align="left">

<html:password property="email" size="30" maxlength="50"/>


</td>

</tr>

<tr>

<td align="right">

<html:submit property="submit" value="submit"/>

</td>

<td align="left">

<html:reset/>

</td>

</tr>

</table>

</html:form>

</body>

</html:html>


  此jsp页面不同于普通的jsp页,因为它大量运用了taglib,这些taglib对初学者而言,可能难于掌握,可这却是struts的精华之一。灵活运用,将大大提高开发效率。





 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons