Struts1.2应用-批量封装对象
++YONG原创,转载请注明
1. 批量发布产品信息效果图:<v:shapetype o:spt="75" coordsize="21600,21600" filled="f" stroked="f" id="_x0000_t75" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t"> <v:shapetype o:spt="75" coordsize="21600,21600" filled="f" stroked="f" id="_x0000_t75" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t"> </v:shapetype></v:shapetype>
<v:shapetype o:spt="75" coordsize="21600,21600" filled="f" stroked="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t"><v:shapetype o:spt="75" coordsize="21600,21600" filled="f" stroked="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" o:connecttype="rect" gradientshapeok="t"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style="WIDTH: 396pt; HEIGHT: 255.75pt"><v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png" o:title=""></v:imagedata></v:shape><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" o:connecttype="rect" gradientshapeok="t"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style="WIDTH: 396pt; HEIGHT: 255.75pt"><v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png" o:title="">
</v:imagedata></v:shape>
<v:shapetype o:spt="75" coordsize="21600,21600" filled="f" stroked="f" id="_x0000_t75" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" o:connecttype="rect" gradientshapeok="t"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style="WIDTH: 396pt; HEIGHT: 255.75pt"><v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png" o:title=""></v:imagedata></v:shape>
上图为批量发布产品页面。

<v:shape id="_x0000_i1026" type="#_x0000_t75" style="WIDTH: 396pt; HEIGHT: 255pt"><v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image003.png" o:title=""></v:imagedata></v:shape>
上图为显示刚批量发布的产品页面。
2. 具体实现:
2.1. 域模型对象:Product.java<o:p></o:p>
|
package org.qiujy.domain;<o:p></o:p> <o:p> </o:p> import java.sql.Date;<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * 产品---实体域模型类<o:p></o:p> * @author qiujy<o:p></o:p> * @version 1.0<o:p></o:p> */<o:p></o:p> public class Product {<o:p></o:p> private Long id;<o:p></o:p> private String name;<o:p></o:p> private double price;<o:p></o:p> private Date pubTime = new Date(new java.util.Date().getTime());<o:p></o:p> <o:p> </o:p> public Product() {<o:p></o:p> }<o:p></o:p> <o:p> </o:p> public Product(Long id, String name, double price, Date pubTime) {<o:p></o:p> this.id = id;<o:p></o:p> this.name = name;<o:p></o:p> this.price = price;<o:p></o:p> this.pubTime = pubTime;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @return the id<o:p></o:p> */<o:p></o:p> public Long getId() {<o:p></o:p> return id;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @param id<o:p></o:p> * the id to set<o:p></o:p> */<o:p></o:p> public void setId(Long id) {<o:p></o:p> this.id = id;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @return the name<o:p></o:p> */<o:p></o:p> public String getName() {<o:p></o:p> return name;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @param name<o:p></o:p> * the name to set<o:p></o:p> */<o:p></o:p> public void setName(String name) {<o:p></o:p> this.name = name;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @return the price<o:p></o:p> */<o:p></o:p> public double getPrice() {<o:p></o:p> return price;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @param price<o:p></o:p> * the price to set<o:p></o:p> */<o:p></o:p> public void setPrice(double price) {<o:p></o:p> this.price = price;<o:p></o:p> }<o:p></o:p> <o:p> </o:p> /**<o:p></o:p> * @return the pubTime |
本文介绍使用Struts1.2框架实现批量发布产品的功能。通过展示具体页面效果及核心代码,详细说明了如何创建产品实体类并利用Struts进行高效的数据处理。
860

被折叠的 条评论
为什么被折叠?



