Java Hour 33 Weather ( 6 )
有句名言,叫做10000小时成为某一个领域的专家。姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧。
Hour 33
CURD 之 Create
首先是Eclipse 排序的功能找到了 - -
Sort Member
从Model开始
package org.apache.struts.helloworld.model; public class Person { private String firstName; private String lastName; private String email; private int age; public int getAge() { return age; } public String getEmail() { return email; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setAge(int age) { this.age = age; } public void setEmail(String email) { this.email = email; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public String toString() { return "First Name: " + getFirstName() + " Last Name: " + getLastName() + " Email: " + getEmail() + " Age: " + getAge(); } }
Register 的View
<?xml version="1.0" encoding="ISO-8859-1" ?> <%@ taglib prefix="s" uri="/struts-tags"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Register</title> </head> <body> <h3>Register for a prize by completing this form.</h3> <s:form action="register"> <s:textfield name="personBean.firstName" label="First name" /> <s:textfield name="personBean.lastName" label="Last name" /> <s:textfield name="personBean.email" label="Email" /> <s:textfield name="personBean.age" label="Age" /> <s:submit /> </s:form> </body> </html>
这里有熟悉的tag, s:from, s:textfield, s:submit
Controller Class 这个最关键了
package org.apache.struts.register.action; import org.apache.struts.register.model.Person; import com.opensymphony.xwork2.ActionSupport; public class Register extends ActionSupport { private static final long serialVersionUID = 1L; private Person personBean; @Override public String execute() throws Exception { // call Service class to store personBean's state in database return SUCCESS; } public Person getPersonBean() { return personBean; } public void setPersonBean(Person person) { personBean = person; } }
一个简单的Success View
<?xml version="1.0" encoding="ISO-8859-1" ?> <%@ taglib prefix="s" uri="/struts-tags"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Registration Successful</title> </head> <body> <h3>Thank you for registering for a prize.</h3> <p> Your registration information: <s:property value="personBean" /> </p> <p> <a href="<s:url action='index' />">Return to home page</a>. </p> </body> </html>
这里就两个tag s:property, s:url
struts.xml 配置映射
<action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute"> <result name="success">/HelloWorld.jsp</result> </action> <action name="register" class="org.apache.struts.register.action.Register" method="execute"> <result name="success">/thankyou.jsp</result> </action>
Result
Java Hour 33 Weather ( 6 )的更多相关文章
- 深入浅出 Java Concurrency (33): 线程池 part 6 线程池的实现及原理 (1)[转]
线程池数据结构与线程构造方法 由于已经看到了ThreadPoolExecutor的源码,因此很容易就看到了ThreadPoolExecutor线程池的数据结构.图1描述了这种数据结构. 图1 Thre ...
- Java hour 52 Weather
采用jetty 后,默认的welcome-file-list 配置失效了,直接跳转到了struts2 的control 中去了. <welcome-file-list> <welco ...
- Java Hour 21 Weather
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. 本文作者Java 现经验约为21 Hour,请各位不吝赐教. 继续心情不佳,那 ...
- java进阶(33)--IO流
一.IO流概念:1.基本概念2.IO流分类3.java.io流的四大家族4.流的close和flush方法5.java.id下常用的16个流 二.FileInputStream字节输入流1.FileI ...
- Java Hour 43 Weather ( 12 ) - 杭州 Show
终于从fastjson 的阴影中走出来了,接下去就是显示一个完整的天气信息了. 43.1 Weather Show 首先增加Model 中的属性. public class Weatherinfo { ...
- Java Hour 38 Weather ( 11 ) – fastjson
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 38 Java 中的 json 反序列化 其实就是所谓的json 转 ...
- Java Hour 37 Weather ( 10 )
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 36 Weather 从失败的地方爬起来 在jsp 中,使用EL 表 ...
- Java Hour 35 Weather ( 8 ) struts2 – message resource
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 35 刚发表了一条闪存,在这个公司快满3个月了,该正式决定留下来还是 ...
- Java Hour 32 Weather ( 5 ) struts2 – Action class
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 32 Struts2 Action 1 将action 映射到 ac ...
随机推荐
- 在不借助其他工具的情况下破解Windows开机密码
文章:http://www.cnblogs.com/vforbox/p/4828855.html#!comments. 从该文章我们也可以得到一个快速启动某个程序的方法:将自己常用的程序命名为seth ...
- Ubuntu技巧之 is not in the sudoers file解决方法
转自:http://www.linuxidc.com/Linux/2010-12/30386.htm 1)进入到root用户下. 2)添加文件的写权限.也就是输入命令"chmod u+w / ...
- NBUT1541 Rainwater 题解
http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1541 When rain, nocLyt discovered a magical phenomeno ...
- CSS3 Media Queries模板
使用max-width @media screen and (max-width: 600px) { //你的样式放在这里.... } 使用min-width @media screen and (m ...
- IOC和AOP的基础原理
IoC(Inversion of Control)就是由容器控制程序之间的关系,而非传统实现中,由程序代码直接操控.这也就是所谓“控制反转”的概念所在.控制权由应用代码中转到了外部容器,控制权的转移是 ...
- UITableview reloadData Animation 动画效果
http://blog.kingiol.com/blog/2013/10/22/uitableview-reloaddata-with-animation/ 运用到UITableview进行重新加载数 ...
- TFS增加dataserver
通过之前的努力,已经搭建好了一套基本的tfs环境,包括一台nameserver和一台dataserver以及独立的nginx-tfs,而在实际应用中的分布式文件系统,只有一台dataserver明显是 ...
- 每天一个命令day1【diff 命令】(具体实例看下一节)
diff 命令是 linux上非常重要的工具,用于比较文件的内容,特别是比较两个版本不同的文件以找到改动的地方.diff在命令行中打印每一个行的改动.最新版本的diff还支持二进制文件.diff程序的 ...
- [转]Spring的IOC原理[通俗解释一下]
1. IoC理论的背景我们都知道,在采用面向对象方法设计的软件系统中,它的底层实现都是由N个对象组成的,所有的对象通过彼此的合作,最终实现系统的业务逻辑. 图1:软件系统中耦合的对象 如果我们打开机械 ...
- Android 相机对焦模式
Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE Camer ...