日期:2014-05-16 浏览次数:20349 次
ORDER.XML <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.model.Order" table="t_order" lazy="false"> <id name="orderId" column="OrderId"> <generator class="uuid.hex" /> </id> <property name="name" column="Name" type="string" /> <property name="desn" column="Desn" type="string"/> <property name="booktime" column="Booktime" type="string"/> <property name="company" column="Company" /> <many-to-one lazy="false" name="custom" column="CustomId" class="com.model.Customer" /> </class> </hibernate-mapping> CUSTOM.XML <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.model.Custom" table="t_custom" lazy="false"> <id name="customId" column="Id"> <generator class="uuid.hex" /> </id> <property name="customName" column="Name" type="string" /> </class> </hibernate-mapping>
import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import net.sf.json.*; //具体的那些serivce的包引入我就省略了 public class OrderAction extends ActionSupport { private static final long serialVersionUID = -5092865658281004791L; private IOrderSerivce orderSerivce; private String jsonString;//这个就是中转站了 private List<Order> orderList;//这个是数据链表 private int totalCount;//这个是extjs用来分页 public String getJsonString() { return jsonString; } public void setJsonString(String jsonString) { this.jsonString = jsonString; } public int getTotalCount() { return totalCount; } public void setTotalCount(int totalCount) { this.totalCount = totalCount; } public List<Air> getOrderList() { return orderList; } public void setOrderList(List<Order> orderList) { this.orderList = orderList; } public void setOrderSerivce(OrderSerivce orderSerivce) { this.orderSerivce = orderSerivce; } public String getAllAir() { orderList = orderSerivce.getOrderAll(); this.setTotalCount(orderList.size()); JSONArray array = JSONArray.fromObject(orderList); //哈哈,就是在这里进行转换的 this.jsonString = "{totalCount:"+this.getTotalCount()+",results:"+array.toString()+"}"; return SUCCESS; } } 接下来再是什么,哦,是的,应该是STRUTS的配置了,哈哈 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">