?
在此要實現afterPropertiesSet接口,afterPropertiesSet()中的方法會隨系統啟動時自動執行,可做一些系統參數初始化使用
或者在action中也可以實現
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.context.WebApplicationContext;
public class FacadeExporterAction extends BaseAction implements ApplicationContextAware{
}
可以利用set方法賦初值
??????? <servlet-class>com.lion.cms.frontend.servlet.SimpleUploaderServlet</servlet-class>
.......................................
servlet代碼如下:
package com.lion.cms.frontend.servlet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import org.apache.commons.fileupload.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
/**
?* Servlet to upload files.<br>
?*
?* This servlet accepts just file uploads, eventually with a parameter specifying file type
?*
?* @author Simone Chiaretta (simo@users.sourceforge.net)
?*/
public class SimpleUploaderServlet extends HttpServlet {
???
??? private static String baseDir;
??? private static boolean debug=false;
??? private static boolean enabled=false;
??? private static Hashtable allowedExtensions;
??? private static Hashtable deniedExtensions;
???
??? /**
???? * Initialize the servlet.<br>
???? * Retrieve from the servlet configuration the "baseDir" which is the root of the file repository:<br>
???? * If not specified the value of "/UserFiles/" will be used.<br>
???? * Also it retrieve all allowed and denied extensions to be handled.
???? *
???? */
???? public void init() throws ServletException {
???????
??????? debug=(new Boolean(getInitParameter("debug"))).booleanValue();
???????
??????? if(debug) System.out.println("\r\n---- SimpleUploaderServlet initialization started ----");
???????
??????? baseDir=getInitParameter("baseDir");
??????? enabled=(new Boolean(getInitParameter("enabled"))).booleanValue();
??????? if(baseDir==null)
??????????? baseDir="/UserFiles/";
??????? String realBaseDir=getServletContext().getRealPath(baseDir);
??????? File baseFile=new File(realBaseDir);
??????? if(!baseFile.exists()){
??????????? baseFile.mkdir();
??????? }
???????
??????? allowedExtensions = new Hashtable(3);
??????? deniedExtensions = new Hashtable(3);
???????????????
??????? allowedExtensions.put("File",stringToArrayList(getInitParameter("AllowedExtensionsFile")));
??????? deniedExtensions.put("File",stringToArrayList(getInitParameter("DeniedExtensionsFile")));
??????? allowedExtensions.put("Image",stringToArrayList(getInitParameter("AllowedExtensionsImage")));
??????? deniedExtensions.put("Image",stringToArrayList(getInitParameter("DeniedExtensionsImage")));
???????
??????? allowedExtensions.put("Flash",stringToArrayList(getInitParameter("AllowedExtensionsFlash")));
??????? deniedExtensions.put("Flash",stringToArrayList(getInitParameter("DeniedExtensionsFlash")));
???????
??????? if(debug) System.out.println("---- SimpleUploaderServlet initialization completed ----\r\n");
???????
??? }
???
??? /**
???? * Manage the Upload requests.<br>
???? *
???? * The servlet accepts commands sent in the following format:<br>
???? * simpleUploader?Type=ResourceType<br><br>
???? * It store the file (renaming it in case a file with the same name exists) and then return an HTML file
???? * with a javascript command in it.
???? *
???? */
??? public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
??????? if (debug) System.out.println("--- BEGIN DOPOST ---");
??????? response.setContentType("text/html; charset=UTF-8");
??????? response.setHeader("Cache-Control","no-cache");
??????? PrintWriter out = response.getWriter();
???????
??????? String typeStr=request.getParameter("Type");
???????
??????? String currentPath=baseDir+typeStr;
??????? String currentDirPath=getServletContext().getRealPath(currentPath);
??????? currentPath=request.getContextPath()+currentPath;
???????
??????? if (debug) System.out.println(currentDirPath);
???????
??????? String retVal="0";
??????? String newName="";
??????? String fileUrl="";
??????? String errorMessage="";
???????
??????? if(enabled) {??????
??????????? DiskFileUpload upload = new DiskFileUpload();
??????????? try {
??????????????? List items = upload.parseRequest(request);
???????????????
??????????????? Map fields=new HashMap();
???????????????
??????????????? Iterator iter = items.iterator();
??????????????? while (iter.hasNext()) {
??????????????????? FileItem item = (FileItem) iter.next();
??????????????????? if (item.isFormField())
??????????????????????? fields.put(item.getFieldName(),item.getString());
??????????????????? else
??????????????????????? fields.put(item.getFieldName(),item);
??????????????? }
??????????????? FileItem uplFile=(FileItem)fields.get("NewFile");
??????????????? String fileNameLong=uplFile.getName();
??????????????? fileNameLong=fileNameLong.replace('\\','/');
??????????????? String[] pathParts=fileNameLong.split("/");
??????????????? String fileName=pathParts[pathParts.length-1];
???????????????
??????????????? String nameWithoutExt=getNameWithoutExtension(fileName);
??????????????? String ext=getExtension(fileName);//后綴名
??????????????? String random=String.valueOf((Math.abs((new Random()).nextInt()) % 10000));//生成隨機數
??????????????? String namebydate=String.valueOf(Calendar.getInstance().getTime().getTime())+ random+"."+ext;
??????????????? File pathToSave=new File(currentDirPath,namebydate);
??????????????? fileUrl=currentPath+"/"+namebydate;//返回上傳后的文件路徑
??????????????
??????????????? if(extIsAllowed(typeStr,ext)) {
??????????????????? int counter=1;
??????????????????? while(pathToSave.exists()){//如果服務器存在同名文件
??????????????????????? newName=nameWithoutExt+"("+counter+")"+"."+ext;//新文件名
??????????????????????? fileUrl=currentPath+"/"+newName;
??????????????????????? retVal="201";
??????????????????????? pathToSave=new File(currentDirPath,newName);
??????????????????????? counter++;
??????????????????????? }
??????????????????? uplFile.write(pathToSave);
??????????????? }
??????????????? else {
??????????????????? retVal="202";
??????????????????? errorMessage="";
??????????????????? if (debug) System.out.println("Invalid file type: " + ext);
??????????????? }
??????????? }catch (Exception ex) {
??????????????? if (debug) ex.printStackTrace();
??????????????? retVal="203";
??????????? }
??????? }
??????? else {
??????????? retVal="1";
??????????? errorMessage="This file uploader is disabled. Please check the WEB-INF/web.xml file";
??????? }
???????
??????? //返回文件路徑到文本框
??????? out.println("<script type=\"text/javascript\">");
??????? out.println("window.parent.OnUploadCompleted("+retVal+",'"+fileUrl+"','"+newName+"','"+errorMessage+"');");
??????? out.println("</script>");
??????? out.flush();
??????? out.close();
???
??????? if (debug) System.out.println("--- END DOPOST ---");???
???????
??? }
??? /*
???? * This method was fixed after Kris Barnhoorn (kurioskronic) submitted SF bug #991489
???? */
??? private static String getNameWithoutExtension(String fileName) {
??????????? return fileName.substring(0, fileName.lastIndexOf("."));
??????? }
???????
??? /*
???? * This method was fixed after Kris Barnhoorn (kurioskronic) submitted SF bug #991489
???? */
??? private String getExtension(String fileName) {
??????? return fileName.substring(fileName.lastIndexOf(".")+1);
??? }
?
??? /**
???? * Helper function to convert the configuration string to an ArrayList.
???? */
????
???? private ArrayList stringToArrayList(String str) {
????
???? if(debug) System.out.println(str);
???? String[] strArr=str.split("\\|");
????????
???? ArrayList tmp=new ArrayList();
???? if(str.length()>0) {
???????? for(int i=0;i<strArr.length;++i) {
??????????????? if(debug) System.out.println(i +" - "+strArr[i]);
??????????????? tmp.add(strArr[i].toLowerCase());
??????????? }
??????? }
??????? return tmp;
???? }
??? /**
???? * Helper function to verify if a file extension is allowed or not allowed.
???? */
????
???? private boolean extIsAllowed(String fileType, String ext) {
???????????
??????????? ext=ext.toLowerCase();
???????????
??????????? ArrayList allowList=(ArrayList)allowedExtensions.get(fileType);
??????????? ArrayList denyList=(ArrayList)deniedExtensions.get(fileType);
???????????
??????????? if(allowList.size()==0)
??????????????? if(denyList.contains(ext))
??????????????????? return false;
??????????????? else
??????????????????? return true;
??????????? if(denyList.size()==0)
??????????????? if(allowList.contains(ext))
??????????????????? return true;
??????????????? else
??????????????????? return false;
????
??????????? return false;
???? }
}
.
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.RenderingHints;
import java.io.PrintWriter;
import javax.servlet.http.HttpSession;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.labels.CategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
public class CategoryItemChart {
?public static String generateBarChart(
???????? HttpSession session,
???????? PrintWriter pw,
???????? int w, int h) {
?String filename = null;
?try {
?CategoryDataset dataset=createDataset();
?JFreeChart chart=ChartFactory.createBarChart(
?"世界傻瓜大獎賽",//圖表標題
?"比賽場次",//X軸標題
?"傻瓜程度",//Y軸標題
?dataset,//數據集合
?PlotOrientation.VERTICAL,//圖表顯示方向(水平、垂直)
?true,//是否使用圖例
?false,//是否使用工具提示
?false//是否為圖表增加URL
?);
?
?/*------------配置圖表屬性--------------*/
?// 1,設置整個圖表背景顏色
?chart.setBackgroundPaint(Color.yellow);
?
?
?/*------------設定Plot參數-------------*/
?CategoryPlot plot=chart.getCategoryPlot();
?// 2,設置詳細圖表的顯示細節部分的背景顏色
?plot.setBackgroundPaint(Color.PINK);
?// 3,設置垂直網格線顏色
?plot.setDomainGridlinePaint(Color.black);
?//4,設置是否顯示垂直網格線
?plot.setDomainGridlinesVisible(true);
?//5,設置水平網格線顏色
?plot.setRangeGridlinePaint(Color.yellow);
?//6,設置是否顯示水平網格線
?plot.setRangeGridlinesVisible(true);
?
?/*---------將所有數據轉換為整數形式---------*/
?final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
?rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
?
?/*---------設置是否在柱圖的狀態條上顯示邊框----*/
?CategoryItemRenderer renderer = (CategoryItemRenderer) plot.getRenderer();
?BarRenderer? render=(BarRenderer) plot.getRenderer();
?render.setItemMargin(0.1);
?
?/*---------設置狀態條顏色的深淺漸變-----------*/
??? GradientPaint gp0 = new GradientPaint(
??????????? 0.0f, 0.0f, new Color(255,200,80),
??????????? 0.0f, 0.0f, new Color(255,255,40)
??????????? );
??? GradientPaint gp1 = new GradientPaint(
??????????? 0.0f, 0.0f, new Color(50,255,50),
??????????? 0.0f, 0.0f, new Color(100,255,100)
??????????? );
??? GradientPaint gp2 = new GradientPaint(
??????????? 0.0f, 0.0f, Color.red,
??????????? 0.0f, 0.0f, new Color(255,100,100)
??????????? );
??? GradientPaint gp3 = new GradientPaint(
??????????????? 0.0f, 0.0f, new Color(108,108,255),
??????????????? 0.0f, 0.0f, new Color(150, 150, 200)
??????????????? );
?????????????
??? renderer.setSeriesPaint(0, gp0);
??? renderer.setSeriesPaint(1, gp1);
??? renderer.setSeriesPaint(2, gp2);
??? renderer.setSeriesPaint(3, gp3);
??? /*
???? *
???? * 解決柱狀體與圖片邊框的間距問題
???? *
???? *
???? * */????????????????
??? /*------設置X軸標題的傾斜程度----*/
??? CategoryAxis domainAxis = plot.getDomainAxis();
??? domainAxis.setCategoryLabelPositions(
??? CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
??? );
??? /*------設置柱狀體與圖片邊框的左右間距--*/
??? domainAxis.setLowerMargin(0.01);
??? domainAxis.setUpperMargin(0.01);
??? /*------設置柱狀體與圖片邊框的上下間距---*/
??? ValueAxis rAxis = plot.getRangeAxis();
??? rAxis.setUpperMargin(0.15);
??? rAxis.setLowerMargin(0.15);
???
??? /*---------設置每一組柱狀體之間的間隔---------*/
??? render.setItemMargin(0.0);
??? /*
???? *
???? * 解決柱狀體與圖片邊框的間距問題
???? *
???? *
???? * */?
???
???
???
???
???
??? /*
???? *
???? *
???? * 解決JFREECHART的中文顯示問題
???? *
???? *
???? * */
???
??? /*----------設置消除字體的鋸齒渲染(解決中文問題)--------------*/
??? chart.getRenderingHints().put(
??????????? RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
??????????? );
??? /*----------設置標題字體--------------------------*/
??? TextTitle textTitle = chart.getTitle();
??? textTitle.setFont(new Font("黑體", Font.PLAIN, 20));???????
??? /*------設置X軸坐標上的文字-----------*/
??? domainAxis.setTickLabelFont(new Font("sans-serif",Font.PLAIN,11));
??? /*------設置X軸的標題文字------------*/
??? domainAxis.setLabelFont(new Font("宋體",Font.PLAIN,12));????????
??? /*------設置Y軸坐標上的文字-----------*/
??? rAxis.setTickLabelFont(new Font("sans-serif",Font.PLAIN,12));
??? /*------設置Y軸的標題文字------------*/
??? rAxis.setLabelFont(new Font("黑體",Font.PLAIN,12));
???
??? /*---------設置柱狀體上的顯示的字體---------*/????????
??? renderer.setItemLabelGenerator(new LabelGenerator(0.0));
??? renderer.setItemLabelFont(new Font("宋體",Font.PLAIN,12));
??? renderer.setItemLabelsVisible(true);
???
??? /*
???? *
???? *
???? * 解決JFREECHART的中文顯示問題
???? *
???? *
???? * */????
?/*------得到chart的保存路徑----*/
??? ChartRenderingInfo info = new ChartRenderingInfo(new
??????????? StandardEntityCollection());
?filename = ServletUtilities.saveChartAsPNG(chart, w, h, info, session);
?
?/*------使用printWriter將文件寫出----*/
?ChartUtilities.writeImageMap(pw, filename, info,true);
?pw.flush();
?
?}
?catch (Exception e) {
?System.out.println("Exception - " + e.toString());
?e.printStackTrace(System.out);
?filename = "public_error_500x300.png";
?}
?return filename;
?}
?
?
?/*-------------設置柱狀體頂端的數據顯示--------------*/
?static class LabelGenerator implements CategoryItemLabelGenerator {
?
?private double threshold;
?
?public LabelGenerator(double threshold) {
?this.threshold = threshold;
?}
?
?public String generateLabel(CategoryDataset dataset,
?int row,int column) {
?String result = null;
?final Number value = dataset.getValue(row, column);
?if (value != null) {
?final double v = value.doubleValue();
?if (v > this.threshold) {
?result = value.toString();
?}
?}
?return result;
?}
?
?public String generateRowLabel(CategoryDataset dataset,
?int row){
?return null;
?
?}
?public String generateColumnLabel(CategoryDataset dataset,
?int column){
?return null;
?}
?
?
?
?}
?/*-----------數據集合封裝-------------*/
?private static CategoryDataset createDataset(){
?String s1="笨笨";
?String s2="蛋蛋";
?String s3="傻傻";
?String s4="瓜瓜";
?
?String c1="第一場";
?String c2="第二場";
?String c3="第三場";
?String c4="第四場";
?String c5="第五場";
?
?/*-------------封裝圖表使用的數據集-------------*/
?DefaultCategoryDataset dataset=new DefaultCategoryDataset();
?dataset.setValue(1.0,s1,c1);
?dataset.setValue(2.0,s1,c2);
?dataset.setValue(3.0,s1,c3);
?dataset.setValue(4.0,s1,c4);
?dataset.setValue(5.0,s1,c5);
?
?dataset.setValue(5.0,s2,c1);
?dataset.setValue(4.0,s2,c2);
?dataset.setValue(3.0,s2,c3);
?dataset.setValue(2.0,s2,c4);
?dataset.setValue(1.0,s2,c5);
?
?dataset.setValue(1.0,s3,c1);
?dataset.setValue(2.0,s3,c2);
?dataset.setValue(3.0,s3,c3);
?dataset.setValue(2.0,s3,c4);
?dataset.setValue(1.0,s3,c5);
?
?dataset.setValue(1.0,s4,c1);
?dataset.setValue(2.0,s4,c2);
?dataset.setValue(3.0,s4,c3);
?dataset.setValue(4.0,s4,c4);
?dataset.setValue(5.0,s4,c5);
?
?
?return dataset;
?}
????
?}
JSP代碼如下:
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.io.PrintWriter"%>
<%@ page import="com.meetexpo.cms.backend.util.CategoryItemChart;"%>
<html>
<head>
<title>
</title>
<%
//以下部分為圖象輸出
String fileName=CategoryItemChart.generateBarChart(session,new PrintWriter(out),580,250);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + fileName;
%>
</head>
<body bgcolor="#ffffff">
<table? width="580" border="0" cellspacing="0" cellpadding="0">
? <tr>
??? <td>
????? <img src="<%= graphURL %>" width=580 height=250 border=0
???????? >
??? </td>
? </tr>
</table>
</body>
</html>
類包是jcommon-1.0.0.jar和jfreechart-1.0.0.jar
??? <servlet-mapping>
??????? <servlet-name>action</servlet-name>
??????? <url-pattern>*.do</url-pattern>
??? </servlet-mapping>
??? <servlet>
??????? <servlet-name>dwr-invoker</servlet-name>
??????? <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
??????? <init-param>
??????????? <param-name>debug</param-name>
??????????? <param-value>true</param-value>
??????? </init-param>
??? </servlet>
??? <servlet-mapping>
??????? <servlet-name>dwr-invoker</servlet-name>
??????? <url-pattern>/dwr/*</url-pattern>
??? </servlet-mapping>
????
??? <context-param>
??????? <param-name>contextConfigLocation</param-name>
??????? <param-value>/WEB-INF/applicationContext.xml
??????? </param-value>
??? </context-param>
??? <listener>
??????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
??? </listener>?
?????
??? <filter>
??????? <filter-name>EncodingFilter</filter-name>
??????? <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
??????? <init-param>
??????????? <param-name>encoding</param-name>
??????????? `
??????????? <param-value>UTF-8</param-value>
??????? </init-param>
??? </filter>
??? <filter-mapping>
??????? <filter-name>EncodingFilter</filter-name>
??????? <url-pattern>/*</url-pattern>
??? </filter-mapping>
????? <error-page>
??????? <error-code>404</error-code>
??????? <location>/404.jsp</location>
??? </error-page>
??? <error-page>
??????? <error-code>500</error-code>
??????? <location>/500.jsp</location>
??? </error-page>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-bean</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-logic</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-html</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/struts-tiles</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
??? </taglib>
??? <taglib>
??????? <taglib-uri>/WEB-INF/ntu</taglib-uri>
??????? <taglib-location>/WEB-INF/tld/ntu.tld</taglib-location>
??? </taglib>
</web-app>
二:spring中注入相關service
<bean id="ajaxTestService" class="com.lion.cms.domain.service.AjaxTestServiceImp">
??????? <property name="commonDAO">
??????????? <ref bean="commonDAO" />
??????? </property>
??? </bean>
三:AjaxTestServiceImp代碼
public class AjaxTestServiceImp implements IAjaxTestService {
??
??? private ICommonDAO commonDAO;
?????
??? public void setCommonDAO(ICommonDAO commonDAO) {
??????? this.commonDAO = commonDAO;
??? }
??? public List getEmployeeById(String deptid) { <dwr> ??<property
??<property
?
??????? DetachedCriteria detachedCriteria=DetachedCriteria.forClass(Employee.class);
??????? detachedCriteria.setFetchMode(Employee.PROP_DEPTID,FetchMode.JOIN);
??????? detachedCriteria.add(Restrictions.eq(Employee.PROP_DEPTID+".id",deptid));
??????? List result=commonDAO.findByCriteria(detachedCriteria);
??????? return result;
???????
??? }
}
四:dwr.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "
?<allow>
??<create creator="spring" javascript="ajaxTestService">
???<param name="beanName" value="ajaxTestService" />
???<include method="getEmployeeById" />
??</create>
??????? <convert converter="bean" match="com.lion.cms.domain.pojo.Employee" />
??????? <param name="exclude" value="com.lion.cms.domain.pojo.Dept"/>
?</allow>
</dwr>
五:jsp頁面
<html:select styleId="deptid" property="deptid" onchange="loadEmployList(this.value)">
??????????????? <html:optionsCollection name="deptlist" label="deptname" value="id"/>
??????????? </html:select>
??????????? <html:select property="employee" styleId="employee">
??????????? <html:option value="" >請選擇</html:option>
??????????? </html:select>????
<script type="text/javascript">
<!--
??? // 加載employee下拉列表。
??? function loadEmployList(deptid){
??????? if(deptid==null||deptid==''){
??????? clearEmployeeSel();
??????? return;
??????? }
??????? ajaxTestService.getEmployeeById(loadEmployListCallback,deptid);
??? }
??? var loadEmployListCallback=function(items){
??????? clearEmployeeSel();
??????? DWRUtil.addOptions("employee",items,"id","truename");
??? }
??? function clearEmployeeSel(){
??????? DWRUtil.removeAllOptions("employee");
??????? DWRUtil.addOptions("employee",[{label:'請選擇',value:''}],"value","label");
??? }
//-->
</script>
職工和部門是多對一關系,例子簡單,不詳細敘述了
dwr中spring和hibernate的配置相關幫助文檔:
http://getahead.ltd.uk/dwr/server/spring
http://getahead.ltd.uk/dwr/server/hibernate
dept.hbm.xml代碼如下:
<hibernate-mapping package="com.lion.cms.domain.pojo">
?<class
?? name="Dept"
??table="dept"
?>
?<meta attribute="sync-DAO">false</meta>
???<id
???name="id"
???type="string"
???column="id"
??>
???<generator class="uuid.hex"/>
??</id>
???name="deptname"
???column="deptname"
???type="string"
???not-null="true"
???length="12"
??/>
??<property
???name="creattime"
???column="creattime"
???type="java.lang.Long"
???not-null="false"
???length="20"
??/>
?
?</class>?
</hibernate-mapping>
employee.hbm.xml代碼如下:
<hibernate-mapping package="com.lion.cms.domain.pojo">
?<class
??name="Employee"
??table="employee"
?>
??<meta attribute="sync-DAO">false</meta>
??<id
???name="id"
???type="string"
???column="Id"
??>
???<generator class="uuid.hex"/>
??</id>
???name="username"
???column="username"
???type="string"
???not-null="true"
???length="20"
??/>
??<property
???name="password"
???column="password"
???type="string"
???not-null="false"
???length="20"
??/>
??<property
???name="truename"
???column="truename"
???type="string"
???not-null="false"
???length="11"
??/>
??<property
???name="sex"
???column="sex"
???type="string"
???not-null="false"
???length="2"
??/>
??<property
???name="intro"
???column="intro"
???type="string"
???not-null="false"
??/>
??<many-to-one
???name="deptid"
???column="deptid"
???class="Dept"
???not-null="true"
??>
??</many-to-one>
?</class>?
</hibernate-mapping>
用hibernate同步插件可以快速生成po
]]>