??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品一区二区三区免费观看,日韩av影片,亚洲精品一区二区三区蜜桃下载http://www.aygfsteel.com/1504/category/37844.html不轻易服?不轻a攑ּ.--心是梦的舞台Q心有多大,舞台有多大。踏t实实做事,认认真真做h?/description>zh-cnThu, 01 Apr 2010 07:29:55 GMTThu, 01 Apr 2010 07:29:55 GMT60HSQL查询q【{ȝ?/title><link>http://www.aygfsteel.com/1504/archive/2009/02/22/256104.html</link><dc:creator>weesun一c阳?/dc:creator><author>weesun一c阳?/author><pubDate>Sun, 22 Feb 2009 11:50:00 GMT</pubDate><guid>http://www.aygfsteel.com/1504/archive/2009/02/22/256104.html</guid><wfw:comment>http://www.aygfsteel.com/1504/comments/256104.html</wfw:comment><comments>http://www.aygfsteel.com/1504/archive/2009/02/22/256104.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/1504/comments/commentRss/256104.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/1504/services/trackbacks/256104.html</trackback:ping><description><![CDATA[<span style="font-size: 12pt;"><span style="font-size: 12pt;">在spring+hibernate中:</span><span style="font-size: 12pt;">Hql</span><span style="font-size: 12pt;">中有中文参数Q如</span><span style="font-size: 12pt;">from test as c where c.name='张三'</span><span style="font-size: 12pt;">Q的话被译?/span><span style="font-size: 12pt;">sql</span><span style="font-size: 12pt;">的时候会出现qQ解军_法是?/span><span style="font-size: 12pt;">application.xml</span><span style="font-size: 12pt;">中加入以下语句: <div id="wmqeeuq" class="dp-highlighter"> <ol class="dp-xml"> <li id="wmqeeuq" class="alt"><span id="wmqeeuq" class="tag"><<span id="wmqeeuq" class="tag-name">prop</span> <span id="wmqeeuq" class="attribute">key</span>=<span id="wmqeeuq" class="attribute-value">"hibernate.query.factory_class"</span><span id="wmqeeuq" class="tag">></span>  </span> </li> <li id="wmqeeuq" class="">    org.hibernate.hql.classic.ClassicQueryTranslatorFactory    </li> <li id="wmqeeuq" class="alt">prop<span id="wmqeeuq" class="tag">></span>   </li> </ol> </div> 在hibernate.cfg.xml   中加入下面的属?  <br />     <br />   <property   name="hibernate.query.factory_class">   <br />     <br />             org.hibernate.hql.classic.ClassicQueryTranslatorFactory   <br />     <br />   </property>  </span></span> <img src ="http://www.aygfsteel.com/1504/aggbug/256104.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/1504/" target="_blank">weesun一c阳?/a> 2009-02-22 19:50 <a href="http://www.aygfsteel.com/1504/archive/2009/02/22/256104.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate3.0中实现模p查询【ȝ?/title><link>http://www.aygfsteel.com/1504/archive/2009/02/22/256103.html</link><dc:creator>weesun一c阳?/dc:creator><author>weesun一c阳?/author><pubDate>Sun, 22 Feb 2009 11:50:00 GMT</pubDate><guid>http://www.aygfsteel.com/1504/archive/2009/02/22/256103.html</guid><wfw:comment>http://www.aygfsteel.com/1504/comments/256103.html</wfw:comment><comments>http://www.aygfsteel.com/1504/archive/2009/02/22/256103.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/1504/comments/commentRss/256103.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/1504/services/trackbacks/256103.html</trackback:ping><description><![CDATA[今天的项目中在用<font style="background-color: #c7edcc;" size="3">Hibernate3.0</font>q行模糊查询的时候,出现中文qQ在|上查了好久资料Q终于解决了Q现在把整理后的贴出来?br /> Hibernate中实现模p查询,可有以下三种方式Q?<br /> <br /> W一U方式:QBC查询 <br /> String name = "", info = ""; <br /> if (sub != null && sub.getSubname() != null) { <br /> name = sub.getSubname(); <br /> } <br /> if (sub != null && sub.getSubinfo() != null) { <br /> info = sub.getSubinfo(); <br /> } <br /> Criteria cr = session.createCriteria(Subject.class); <br /> cr.add(Expression.like("subname","%"+name+"%")); <br /> cr.add(Expression.like("subinfo","%"+info+"%")); <br /> <br /> W二U方式:HQL查询语句 <br /> String hql = "from Subject as s where s.subname like :name and s.subinfo like :info"; <br /> // 调用session的获得数据列表方法,传递HQL查询语句 <br /> String  subnamevalue="要查询的中文?;<br /> <font style="background-color: #c7edcc;" size="3">String   sql="";<br /> sql   = "from Pfapp  where name like :subname "; </font><br /> <font style="background-color: #c7edcc;" size="3">Query query = session.createQuery(sql); <br /> query.setString("subname","%"+subnamevalue+"%");<br /> </font>System.out.println("*********"+sql); <br /> <br /> 注:Subject为数据库表subject映射的类Q它有相应的属性subname、subinfo及相应的get和setҎQsub为Subject的一个实例化对象?br /> 另外说明的是Q如果你不写对象名称Q直接写字段Q那么hibernate按照数据库字段q行查找 <br /> 如果你写   (对象?对象属性)Q那么hibernate按照ormapping中的映射字段q行查找 <br /> q是hibernate的灵zM处!Q? <img src ="http://www.aygfsteel.com/1504/aggbug/256103.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/1504/" target="_blank">weesun一c阳?/a> 2009-02-22 19:50 <a href="http://www.aygfsteel.com/1504/archive/2009/02/22/256103.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ant-build.xml打包应用E序【ȝ?/title><link>http://www.aygfsteel.com/1504/archive/2009/02/22/256102.html</link><dc:creator>weesun一c阳?/dc:creator><author>weesun一c阳?/author><pubDate>Sun, 22 Feb 2009 11:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/1504/archive/2009/02/22/256102.html</guid><wfw:comment>http://www.aygfsteel.com/1504/comments/256102.html</wfw:comment><comments>http://www.aygfsteel.com/1504/archive/2009/02/22/256102.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/1504/comments/commentRss/256102.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/1504/services/trackbacks/256102.html</trackback:ping><description><![CDATA[<p>弄了好久的ant打包l于明白了,贴出来大家分享?font style="background-color: #c7edcc;" size="3"><br /> <?xml version="1.0" encoding="UTF-8"?><br /> <project name="gpdi" basedir="." default="deploy"><br />  <!-- Properties and Paths --><br />  <property name="dir.java.src" value="src" /><br />  <br />  <property name="dir.java.build" value="defaultroot/WEB-INF/classes" /><br />   <br />  <property name="dir.lib" value="lib" /><br />   <br />  <property name="dir.deploy" value="deploy" /></font></p> <p><font style="background-color: #c7edcc;" size="3"> <property name="file.manifest" value="manifest.txt" /></font></p> <p><font style="background-color: #c7edcc;" size="3"> <property name="file.jar" value="gpdi.jar" /><br />  <!-- Just to fool the test --><br />  <property name="gpdi.root" value="." /><br />     <!-- 排除java源文件的模式?--><br />     <patternset id="no.java"><br />         <exclude name="**/*.java" /><br />     </patternset><br />  <path id="project.class.path"><br />   <pathelement location="${dir.java.build}"/><br />   <fileset dir="${dir.lib}" id="lib.path"><br />    <include name="**/*.jar"/><br />   </fileset><br />    <br />  </path><br />  <br />     <!-- 初始?建立目录,复制文g --><br />  <br />     <target name="init" depends="clean" description="初始?建立目录,复制文g"></font></p> <p><font style="background-color: #c7edcc;" size="3">        <mkdir dir="${dir.java.build}" /></font></p> <p><font style="background-color: #c7edcc;" size="3">        <mkdir dir="${dir.dist}" /></font></p> <p><font style="background-color: #c7edcc;" size="3">        <copy todir="${dir.java.build}"></font></p> <p><font style="background-color: #c7edcc;" size="3">            <fileset dir="${dir.java.src}"></font></p> <p><font style="background-color: #c7edcc;" size="3">                <patternset refid="no.java" /></font></p> <p><font style="background-color: #c7edcc;" size="3">            </fileset></font></p> <p><font style="background-color: #c7edcc;" size="3">        </copy></font></p> <p><font style="background-color: #c7edcc;" size="3">    </target><br />  <br />     <!-- 清理,删除临时目录 --><br />  <br />     <target name="clean" description="清理,删除临时目录"></font></p> <p><font style="background-color: #c7edcc;" size="3">        <delete dir="${dir.java.build}" /></font></p> <p><font style="background-color: #c7edcc;" size="3">        <delete dir="${dir.dist}" /></font></p> <p><font style="background-color: #c7edcc;" size="3">        <echo level="info">清理完毕</echo></font></p> <p><font style="background-color: #c7edcc;" size="3">    </target><br />  <br />  <!-- ~译源文?-></font></p> <p><font style="background-color: #c7edcc;" size="3"> <target name="compile" <br />   <br />   depends="init" <br />   <br />   description="~译源文?><br />   <br />   <javac srcdir="${dir.java.src}"<br />    <br />    destdir="${dir.java.build}"<br />    <br />    deprecation="off"<br />    <br />    debug="off"<br />    <br />    encoding="gbk"<br />    <br />    source="1.5" <br />    <br />    target="1.5"><br />    <br />    <classpath refid="project.class.path"/><br />    <br />   </javac><br />   <br />  </target></font></p> <p><font style="background-color: #c7edcc;" size="3">    <!-- 创徏清单文g --></font></p> <p><font style="background-color: #c7edcc;" size="3">    <target name="create.manifest" description="创徏清单文g"><br />         <manifest file="${dir.java.src}/${file.manifest}"><br />             <attribute name="Built-By" value="${user.name}" /><br />             <attribute name="Main-Class" value="com.mfsoft.net.task.TaskJob" /><br />             <attribute name="Class-Path" value="lib/log4j-1.2.9.jar lib/classes12.jar lib/joone-engine.jar" /><br />         </manifest></font></p> <p><font style="background-color: #c7edcc;" size="3">    </target></font></p> <p><font style="background-color: #c7edcc;" size="3">    <!-- 打包cL?--><br />  <br />     <target name="deploy" depends="create.manifest" description="打包cL?><br />         <mkdir dir="${dir.deploy}" /><br />         <mkdir dir="${dir.deploy}/log" /><br />         <jar jarfile="${dir.deploy}/${file.jar}" manifest="${dir.java.src}/${file.manifest}"><br />             <fileset dir="${dir.java.build}" includes="db.properties,config.properties,log4j.properties,com/mfsoft/net/task/*.class,com/mfsoft/credit/modelmang/operation/*.class,<br />             com/mfsoft/net/datatranslate/*.class,com/mfsoft/net/pre/*.class,com/mfsoft/icity/platform/database/*.class,com/mfsoft/icity/platform/datashare/*.class,<br />             com/mfsoft/icity/platform/publicclass/*.class,com/mfsoft/credit/viable/*.class" />            <br />         </jar>  <br />   <!--复制用到的库以及其他文g --><br /> <mkdir dir="${dir.deploy}/lib"/><br /> <copy todir="${dir.deploy}/lib"><br />  <fileset dir="defaultroot/WEB-INF/lib" includes="classes12.jar,joone-engine.jar,log4j-1.2.9.jar"/><br /> </copy>  <br /> <mkdir dir="${dir.deploy}/model"/> <br /> <copy todir="${dir.deploy}/model"><br />  <fileset dir="defaultroot/WEB-INF/classes" includes="*.snet"/><br /> </copy> <br />     </target><br /> </project></font></p> <img src ="http://www.aygfsteel.com/1504/aggbug/256102.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/1504/" target="_blank">weesun一c阳?/a> 2009-02-22 19:47 <a href="http://www.aygfsteel.com/1504/archive/2009/02/22/256102.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Struts中Action传参?[ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256101.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:47:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256101.htmlhttp://www.aygfsteel.com/1504/comments/256101.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256101.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256101.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256101.html

public ActionForward userSave(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response) {
  UserForm userForm = (UserForm) form;

  return mapping.findForward("userSave");
 }

//传参?br />  public ActionForward userSave(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response) {
  UserForm userForm = (UserForm) form;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 String path = mapping.findForward("delete").getPath();

  //TODO: d本Action所有的h参数Q将path重新构造,加上h参数

  ActionForward forward= new ActionForward(path+"&pageId=1");
  forward.setRedirect(true);
//传参数后q回
  return forward;

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 // return mapping.findForward("userSave");
 }




]]>
保存和提交按钮事件[ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256100.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:43:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256100.htmlhttp://www.aygfsteel.com/1504/comments/256100.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256100.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256100.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256100.html   
<input type="button" name="save" value="生成表格"onclick="javascript:Save();">
<input type="button" name="commit" value=" 提交 "onclick="javascript:Commit();"> 
2.
 function Save()
    {
     var theForm=document.projectSetForm;
   theForm.action="scoreOperation.do?do=creat";
   theForm.submit();
    }
     function Commit()
    {
     var theForm=document.projectSetForm;
  theForm.action="projectSet.do?do=save";
  theForm.submit();
    }
3.
<html:form action="project/projectSet.do" method="POST" >
 </html:form>

]]>
bean:define id的用[ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256099.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:40:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256099.htmlhttp://www.aygfsteel.com/1504/comments/256099.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256099.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256099.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256099.html<bean:define   id="pagename"   name="requestName"/>  
   
  id:指的是这个bean的唯一名字(可以自由定义或者说可以自定义但是必d一)Q在q里定义的id="pagename" ,在要调用的网里面可以随便的使用和访?  
  name:指的是从上一个页面或者action里面传过来的变量Q可以是Mcd?例如再上一|页定义request.setAttribute("requestName", requestName);)  
  例如Q? 
      我有一个Bean对象User对象Q这个里面保存了admin理员的个h信息Q姓?name)Q性别(sex)、年?age)那么怎么用呢? 
  在action里面你可以把User对象传过? 
  request.setAttribute("user",User);  
  在页? 
  <bean:define   id="admin"   name="user"./>  
  然后可以和bean:write搭配使用  
  <bean:write   name="admin"   property="name"/>  
  <bean:write   name="admin"   property="sex"/>  
  <bean:write   name="admin"   property="age"/>

]]>
Hibernate实现one-to-oneU联保存[自己ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256097.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:38:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256097.htmlhttp://www.aygfsteel.com/1504/comments/256097.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256097.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256097.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256097.htmlhttp://www.aygfsteel.com/1504/admin/EditPosts.aspx?opt=1

在具体的目应用?我们很少会用C对一的联操?且很多时候一对一的操作可以通过多对一实现,但是一对一有自q好处,是在Q何时候都能保证主外键数据的一致?但是多对一的情况下未必能做?
我在目中具体用C一对一的联操?从网上拿?一个例子来?但是没有成功,于是只好自己研究,现在把修改后的代码帖出来.
本例子?font size="3">hibernate3.jar+oracle数据?br /> 库表:
CARD_TEST(CARDID[NUMBER(18)],CARDNUM[VARCHAR2(20)])
USER_TEST(USERID[NUMBER(18)],USERNAME[VARCHAR2(20)])
TestMain.java

package com.gpdi.test;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class TestMain {
/**
 * 存储一个用?br />  * @param user
 */
public void save(User user){
 user.setUsername("TEST");
 Card card=new Card();
 //Card card1=new Card();
 card.setCardnum("HGJUYT");
 //card1.setCardnum("fghy55");
 user.setCard(card);
 //user.setCard(card1);
 Session session=HibernateSessionFactory.currentSession();
    card.setUser(user);
    //card1.setUser(user);
 Transaction tr=session.beginTransaction();
 session.save(user);
 //session.save(card);
 tr.commit();
 session.close(); 
}

 public static void main(String[] args) throws Exception {
  TestMain test=new TestMain();
     test.save(new User());
 }

}
Card.java

package com.gpdi.test;

/**
 * Card generated by MyEclipse - Hibernate Tools
 */

public class Card  implements java.io.Serializable {
    // Fields   

     private Integer cardid;
     private String cardnum;
     private User user;

    // Constructors

    public User getUser() {
  return user;
 }
 public void setUser(User user) {
  this.user = user;
 }
 /** default constructor */
    public Card() {
    }
    /** full constructor */
    public Card(String cardnum) {
        this.cardnum = cardnum;
    }
    // Property accessors

    public Integer getCardid() {
        return this.cardid;
    }
   
    public void setCardid(Integer cardid) {
        this.cardid = cardid;
    }

    public String getCardnum() {
        return this.cardnum;
    }
   
    public void setCardnum(String cardnum) {
        this.cardnum = cardnum;
    }

}

User.java
package com.gpdi.test;

import java.util.HashSet;
import java.util.Set;

/**
 * User generated by MyEclipse - Hibernate Tools
 */

public class User  implements java.io.Serializable {
    // Fields   

     private Integer userid;
     private String username;
     private Card card;
     //private Set card = new HashSet();

    // Constructors

    public Card getCard() {
  return card;
 }

 public void setCard(Card card) {
  this.card = card;
 }

 /** default constructor */
    public User() {
    }

    /** full constructor */
    public User(String username) {
        this.username = username;
    }

    // Property accessors

    public Integer getUserid() {
        return this.userid;
    }
   
    public void setUserid(Integer userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return this.username;
    }
   
    public void setUsername(String username) {
        this.username = username;
    }
}
HibernateSessionFactory.java

package com.gpdi.test;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;

/**
 * Configures and provides access to Hibernate sessions, tied to the
 * current thread of execution.  Follows the Thread Local Session
 * pattern, see {@link http://hibernate.org/42.html}.
 */
public class HibernateSessionFactory {

    /**
     * Location of hibernate.cfg.xml file.
     * NOTICE: Location should be on the classpath as Hibernate uses
     * #resourceAsStream style lookup for its configuration file. That
     * is place the config file in a Java package - the default location
     * is the default Java package.<br><br>
     * Examples: <br>
     * <code>CONFIG_FILE_LOCATION = "/hibernate.conf.xml".
     * CONFIG_FILE_LOCATION = "/com/foo/bar/myhiberstuff.conf.xml".</code>
     */
    private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";

    /** Holds a single instance of Session */
 private static final ThreadLocal threadLocal = new ThreadLocal();

    /** The single instance of hibernate configuration */
    private static final Configuration cfg = new Configuration();

    /** The single instance of hibernate SessionFactory */
    private static org.hibernate.SessionFactory sessionFactory;

    /**
     * Returns the ThreadLocal Session instance.  Lazy initialize
     * the <code>SessionFactory</code> if needed.
     *
     *  @return Session
     *  @throws HibernateException
     */
    public static Session currentSession() throws HibernateException {
        Session session = (Session) threadLocal.get();

  if (session == null || !session.isOpen()) {
   if (sessionFactory == null) {
    try {
     cfg.configure(CONFIG_FILE_LOCATION);
     sessionFactory = cfg.buildSessionFactory();
    } catch (Exception e) {
     System.err
       .println("%%%% Error Creating SessionFactory %%%%");
     e.printStackTrace();
    }
   }
   session = (sessionFactory != null) ? sessionFactory.openSession()
     : null;
   threadLocal.set(session);
  }

        return session;
    }

    /**
     *  Close the single hibernate session instance.
     *
     *  @throws HibernateException
     */
    public static void closeSession() throws HibernateException {
        Session session = (Session) threadLocal.get();
        threadLocal.set(null);

        if (session != null) {
            session.close();
        }
    }

    /**
     * Default constructor.
     */
    private HibernateSessionFactory() {
    }

}
Card.hbm.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">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="com.gpdi.test.Card" table="CARD_TEST">
 
        <id name="cardid" type="integer">
            <column name="CARDID" />
            <generator class="foreign" >
            <param name="property">user</param>
            </generator>
        </id>
        <property name="cardnum" type="string">
            <column name="CARDNUM" length="45" not-null="true" />
        </property>
        <!--
        foreign-key="userid"指定外键兌的字D?必须,不可~少 ,cascade="save-update"指定怎么操作U联,非必?br />         -->
       <one-to-one name="user" foreign-key="userid" class="com.gpdi.test.User" cascade="save-update"></one-to-one>
    </class>
</hibernate-mapping>

User.hbm.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">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="com.gpdi.test.User" table="USER_TEST">
        <id name="userid" type="integer">
            <column name="USERID" />
            <generator class="increment"/>
        </id>
        <property name="username" type="string">
            <column name="username" length="45" not-null="true" />
        </property>
        <one-to-one name="card" foreign-key="cardid" class="com.gpdi.test.Card" cascade="save-update"></one-to-one>
        <!--
       <set name="card" inverse="true" cascade="all">
        <key column="cardid" />
        <one-to-many class="com.gpdi.test.Card" />
        </set>
         <many-to-one  name="card" class="com.gpdi.test.Card"  insert="true" unique="true" lazy="false">
         <column name="cardid"  length="18"  />
        </many-to-one>
        -->
 
    </class>
</hibernate-mapping>
http://www.aygfsteel.com/Files/1504/one-to--one.rar


]]>
Hibernate一对多双向兌及inverse的作用[整理ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256095.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:36:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256095.htmlhttp://www.aygfsteel.com/1504/comments/256095.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256095.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256095.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256095.htmlhttp://www.aygfsteel.com/Files/1504/Hibernate-onetomany.txt一个一对多的完整例?资料来源|络,q行整理.
people表:{peopleId,name}

address表:{addressId,peopleId,addressName,codeNumber}

package com.gpdi.test;

import org.hibernate.Session;

import com.gpdi.orm.object.Address;
import com.gpdi.orm.object.People;

public class Testp {

 /**
  * @param args
  */
 public static void main(String[] args)
 {
  People people = new People();
  people.setName("linda");
  Address address = new Address();
  address.setAddressName("yunnan");
  address.setCodeNumber("564123");
  address.setPeople(people);
  people.getAddresses().add(address);
  Session session = HibernateSessionFactory.currentSession();
  session.beginTransaction();
  session.save(people);
  session.getTransaction().commit();

 }

}

People.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="com.gpdi.orm.object.People" table="People">
  <id name="id" column="peopleId" unsaved-value="0" >
  <generator class="increment">
  </generator>
  </id>
  <property name="name" column="name"></property>
  <set name="addresses" cascade="save-update">
  <key column="peopleId" not-null="true" />
  <one-to-many class="com.gpdi.orm.object.Address"/>
  </set>

    </class>
</hibernate-mapping>

People.java

package com.gpdi.orm.object;

import java.util.HashSet;
import java.util.Set;

public class People implements java.io.Serializable
{
 private long id;
 private String name;
 private Set addresses = new HashSet();
 public Set getAddresses() {
  return addresses;
 }
 public void setAddresses(Set addresses) {
  this.addresses = addresses;
 }
 public long getId() {
  return id;
 }
 public void setId(long id) {
  this.id = id;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }

}

Address.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="com.gpdi.orm.object.Address" table="Address">
 <id name="id" column="addressId" unsaved-value="0">
 <generator class="increment">
 </generator>
 </id>
 <many-to-one name="people" column="peopleId" insert="false" update="false"></many-to-one>
 <property name="addressName" column="addressName"></property>
 <property name="codeNumber" column="codeNumber"></property>
    </class>
</hibernate-mapping>

Address.java
package com.gpdi.orm.object;
public class Address implements java.io.Serializable
{
 private long id;
 private People people;
 private String addressName;
 private String codeNumber;
 public String getAddressName() {
  return addressName;
 }
 public void setAddressName(String addressName) {
  this.addressName = addressName;
 }
 public String getCodeNumber() {
  return codeNumber;
 }
 public void setCodeNumber(String codeNumber) {
  this.codeNumber = codeNumber;
 }
 public long getId() {
  return id;
 }
 public void setId(long id) {
  this.id = id;
 }
 public People getPeople() {
  return people;
 }
 public void setPeople(People people) {
  this.people = people;
 }
}
下蝲例子:整理?br /> 一对多的完整例?/a>
下蝲例子:整理?br />



]]>
AJAX和Struts的action交互使用[原创ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256094.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:34:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256094.htmlhttp://www.aygfsteel.com/1504/comments/256094.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256094.html#Feedback1http://www.aygfsteel.com/1504/comments/commentRss/256094.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256094.html1.h面的JS,客户端实?br /> <script type="text/javascript">
 var flagvalue=0;
 var rest="";
 var resta="";
 //实现AJAX验证
 var http_request = false;
 var infoForm_flag=false;
 var lotId="";
function Save()
{
   
      var infoForm=document.projectSetForm;
      infoForm_flag=infoForm;
      lotId=infoForm.lotId.value;
      //表名U?br />       var dc = infoForm.tablename.value;
      if(dc==""||dc==null){
       alert("表名UC能ؓI?");
       infoForm.tablename.focus();
       infoForm.tablename.select();
       return false;
 }
function send_request(url)
  {//初始化、指定处理函数、发送请求的函数
    http_request = false;
    //开始初始化XMLHttpRequest对象
    if(window.XMLHttpRequest)
    { //Mozilla 览?br />       http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType)
      {//讄MiMEcd
           http_request.overrideMimeType('text/xml');
      }
    }
    else if (window.ActiveXObject)
    { // IE览?br />       try
      {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
      }
       catch (e)
      {
        try
        {
             http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
        }
      }
    }
    if (!http_request) { // 异常Q创建对象实例失?br />      window.alert("不能创徏XMLHttpRequest对象实例.");
     return false;
    }
    http_request.onreadystatechange = processRequest;
    // 定发送请求的方式和URL以及是否同步执行下段代码
    http_request.open("GET", url, true);
    http_request.send(null);
  }
     //处理q回信息的函?br />      function processRequest()
     {
         if (http_request.readyState == 4)
         {
             //判断对象状?br />              if (http_request.status == 200)
             {
                 //信息已经成功q回Q开始处理信?br />                  var str=http_request.responseText;//获得从服务器q回的文本信?br />                  if(str=="no")
                 {
                     alert("您选择了模型分属不同的模板,请选择同一模板对应是模?");
                     //return false;
                     infoForm_flag.action="projectSet.do?do=add&lotId="+lotId;
                     infoForm_flag.submit();
                 }
                 else
                 {
                  infoForm_flag.action="projectSet.do?do=creattable&save=-1";
               infoForm_flag.submit();
              }
             } else
             {
                 //面不正?br />                  alert("您所h的页面有异常?);
             }
         }
     }
  function userCheck()
  {
    send_request('projectSet.do?do=check&rest='+rest);
  }
</script>
2.ProjectSetAction.java

package com.gpdi.softevaluate.action;

import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ProjectSetAction extends DispatchAction
{
         

/**
  * <p>模板验证</p>
  * @param mapping
  * @param form
  * @param request
  * @param response
  * @return
  * @throws Exception
  */
 public ActionForward check(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception
 {
   String rest="";
   String lotId="";
   String retn="";
   String flag="";
   CommDaoFactory mgObj = new CommDaoFactory();
   try
   {
       rest=request.getParameter("rest");
       lotId=request.getParameter("lotId");
   }
   catch(Exception e)
   {
   
   }
if(!rest.equals("0")||!rest.equals("")||rest!=null)
 {
     flag="no";
}
else
{
      flag="ok";

}
       PrintWriter out=response.getWriter();
//服务器返回信?br />        out.write(flag);
       out.close();
     //d本Action所有的h参数Q将path重新构造,加上h参数

     //ActionForward forward= new ActionForward("project/projectSet.do?do=add&lotId=6");
     //forward.setRedirect(true);
      //传参数后q回
     //return forward;    
    return mapping.findForward(null);
 
 }
public ActionForward creattable(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception
{
     //实现功能代码
return mapping.findForward("create");
}

}
3.struts.config.xml
 <action attribute="projectSetForm" name="projectSetForm"
    parameter="do" path="/project/projectSet" scope="request"
       type="com.gpdi.softevaluate.action.ProjectSetAction" validate="false">
   <forward name="list" path="/project/viewProject.jsp" />
   <forward name="add" path="/project/addProject.jsp" />
   <forward name="create" path="/project/createTable.jsp" />
  </action>



]]>
L数组中重复的数字[原创]http://www.aygfsteel.com/1504/archive/2009/02/22/256093.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:32:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256093.htmlhttp://www.aygfsteel.com/1504/comments/256093.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256093.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256093.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256093.htmlpublic static ArrayList RemoveRepeatNumber(String[]input)
 {
    ArrayList   arraylist=new   ArrayList();  
    int k=0;
    for(int i = 0;i<input.length;i++)  
    {  
     boolean exist=true;  
     for(int j=0;j<arraylist.size();j++)  
     {  
      if(arraylist.get(j).toString().equals(input[i]) ) 
      {  
       exist=false;  
       break;  
      }  
     }  
     if(exist)
     {
         arraylist.add(k,input[i]); 
         k+=1;
     }
    } 
    return arraylist;
 }
 public static void main(String[]args)
 {
  String []st={"30","30","29"};
  ArrayList str =RemoveRepeatNumber(st);
  for(int i=0;i<str.size();i++)
  {
   System.out.println(str.get(i));
  }
 }

]]>
判断数组中是否有重复是数字[原创]http://www.aygfsteel.com/1504/archive/2009/02/22/256092.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:32:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256092.htmlhttp://www.aygfsteel.com/1504/comments/256092.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256092.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256092.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256092.htmlpublic static boolean judgeEqual(String[]model)
 {
  /**无重复ؓfalse,有重复ؓtrue*/
  boolean flag=false;
  Set  set  =  new  HashSet(); 
  for(int  i  =  0;i<model.length;i++)
  { 
     if(!model[0].equals(model[i]))
     {
      flag=false;
     }
     else
     {
      flag=true;
     }
  } 
  
  return flag;
 }
 public static void main(String[]args)
 {
       String[] s  = {"1","1","1","1","1"};  
      System.out.println(judgeEqual(s));
 }


]]>
checkbox多选[ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256090.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:27:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256090.htmlhttp://www.aygfsteel.com/1504/comments/256090.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256090.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256090.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256090.html1.
<td width="5%" class=content><div align="center">全?lt;input type=checkbox name = "check" onclick = "javascript:allcheck();"></div></td>
2.   
 <td width=5%>
       <div align="center">
        <input type="checkbox" name="checkboxDelete"
         value="<bean:write name="po" property="projectid" />">
       </div>
      </td>

js代码:
 <script language="javascript">
 var tag = false;
function doDelete()
{
 if(deletecheck())
 {
     var theForm=document.projectSetForm;
  theForm.action = "projectSet.do?do=delete&lotId=<%=request.getParameter("lotId") %>";
  theForm.submit();
 
 }
}
function deletecheck()
{
 var theForm = document.projectSetForm;
 var checked = false;
 if(typeof(theForm.checkboxDelete.length)=="undefined"){
  if(theForm.checkboxDelete.checked == true){
  checked = true;
  }
 }else{
 var len = theForm.checkboxDelete.length;
 for (var i=0;i<len;i++){
  if(theForm.checkboxDelete[i].checked == true){
  checked = true;
  break;
  }
   }
 }
 if(!checked){
 alert("误选择一条要删除的记录!")
 return(false);
 }
 
 if(confirm("定要删除吗Q?)){
  return(true);
  }
 return(false);
}
function allcheck(){
 var theForm = document.projectSetForm;
 var len = theForm.checkboxDelete.length;
 var i = 0
 if (tag == false)
  for (i=0;i<len;i++){
   theForm.checkboxDelete[i].checked = true;
   tag = true;
   }
  
 else{
  for ( i=0;i<len;i++){
   theForm.checkboxDelete[i].checked = false;
   tag = false;
  }
 }
}
</script>



]]>
JSP实现EXCEL导出[ȝ原创]http://www.aygfsteel.com/1504/archive/2009/02/22/256089.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:27:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256089.htmlhttp://www.aygfsteel.com/1504/comments/256089.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256089.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256089.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256089.html1.JSP面
<td width=165>
<div align="left">
<!-- d  2008-04-11 16:42 -->
<bean:define id="scoreId" name='Info' property='scoreId' /> 
<a href="scoreSet.do?do=importScore&scoreid=<%=scoreId%>" target="scoreexel">l计导出</a> 
<!--
<html:link action="softevaluate/scoreSet.do?do=setScore" paramName="Info" paramProperty="scoreId" paramId="scoreId">
参数讄
</html:link>
<!-- 
<a href="scoreOperation.do?do=scoreSetE&scoreid=<%=scoreId%>" target="scoreexel">l计导出</a>   
<a href="scoreOperation.do?do=scoreSetE&scoreid=<%=scoreId%>">l计导出</a>
<a href="softevaluate/scoreSet.do?do=setScore">l计导出</a>
-->
</div>
</td> 
2.ScoreSetAction.java
public class ScoreSetAction extends DispatchAction
{
         /******实现EXCEL数据导出*******/
  public ActionForward importScore(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
  {
 
   // 导出数据cdQ此处是写死的ؓ3?br />    String scoreid = request.getParameter("scoreid");
   String []str=new String[3];
   scoreid=scoreid.replace("/", "");
   String maxscore = "";
   String minscore = "";

   ScoreSetExport scoreSetExport = new ScoreSetExport();
   LinkedHashMap hm = new LinkedHashMap();
   SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
   org.hibernate.classic.Session session = sessionFactory.openSession();
   Query query =session.createQuery("from ScoreViable");
   List users=query.list();
   session.close();
   sessionFactory.close();
   for (ListIterator iterator = users.listIterator(); iterator.hasNext(); )
   {
    ScoreViable user = (ScoreViable) iterator.next();
    System.out.println(user.getBeforCount() +"\n\tAge: " + user.getEndCount());
    maxscore=user.getBeforCount()+"";
    minscore=user.getEndCount()+"";
   }
   str[0]=scoreid;
   str[1]=maxscore;
   str[2]=minscore;
   List<ScoreRecordDetail> list = scoreSetExport.exportScoreSet(str,hm);
   ExcelManagerIf eem = ExcelManagerFactory.getInstance();
   /******************************************************************/
   /**不去掉一行仍然调用export,L一行调用export1,只针对一U汇d?/
   //eem.export(response, list,hm);
   eem.export1(response, list,hm);
   /******************************************************************/
   return null;
  }
}
3.ExcelManagerIf.java
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.gpdi.orm.object.ScoreRecordDetail;

public interface ExcelManagerIf
{
 
 /********************************************************************************************************/
 /** 2008-04-18 11:54*/
 public boolean export1(HttpServletResponse response, List<ScoreRecordDetail> list,LinkedHashMap hashMap);
 /********************************************************************************************************/
 
}
4.ExcelManagerFactory.java
public class ExcelManagerFactory
 {
   private static String key = "key";
   private ExcelManagerFactory() {
   }
  
   private static ExcelManagerIf instance = null;
   public static ExcelManagerIf getInstance(){
    if(instance == null){
             synchronized(key){
                 if(instance == null){
                     instance = new ExcelManagerImpl();
                 }
             }
         }
         return instance;
   }
}
5.ExcelManagerImpl.java
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFFooter;
import org.apache.poi.hssf.usermodel.HSSFHeader;
import org.apache.poi.hssf.usermodel.HSSFPalette;
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.Region;
import org.hibernate.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;

 

public class ExcelManagerImpl implements ExcelManagerIf
{
         /***************************************************************************************************************/
/**2008-04-18 11:36   汇d出去掉无用的I格*/
 public boolean export1(HttpServletResponse response, List<ScoreRecordDetail> list,LinkedHashMap hashMap) {
  Session session = null;
  try {
   // 生成电子表格文g
   HSSFWorkbook wb = new HSSFWorkbook();
   // 通过先徏立表|后命名可以定义用的~码Q从而保证汉字的正常昄
   HSSFSheet sheet1 = wb.createSheet();
   /********************************************/
   /**d 2008-04-15导出打印默认方式,trueQ横?nbsp;    falseQ纵?/
   sheet1.getPrintSetup().setLandscape(true);  
   /********************************************/
   sheet1.setColumnWidth((short) 0, (short) 5000);
   sheet1.setColumnWidth((short) 1, (short) 5000);
   sheet1.setColumnWidth((short) 2, (short) 5000);
   sheet1.setColumnWidth((short) 3, (short) 5000);
   // wb.setSheetName(0, "开发商资料",HSSFWorkbook.ENCODING_UTF_16);

   // HSSFRow row;

   // 先定义一个字体对?br />    HSSFFont font = wb.createFont();
   font.setFontName("宋体");
   font.setFontHeightInPoints((short) 16);// 字体大小
   font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗

   // 定义表头单元格格?br />    HSSFCellStyle cellStyle = wb.createCellStyle();
   cellStyle.setFont(font);// 单元格字?br />    cellStyle.setBorderBottom(cellStyle.BORDER_THIN);// 单元D?br />    cellStyle.setBorderTop(cellStyle.BORDER_THIN);
   cellStyle.setBorderRight(cellStyle.BORDER_THIN);
   cellStyle.setBorderLeft(cellStyle.BORDER_THIN);
   cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水^寚w方式

   // 定义新的调色板以便定义自q颜色
   HSSFPalette palette = wb.getCustomPalette();
   // 替换一个默认调色板中已l定义的颜色
   palette.setColorAtIndex(HSSFColor.BLUE_GREY.index, (byte) 230, (byte) 230, (byte) 255);
   // 使用刚才定义的颜色ؓ填充?br />    cellStyle.setFillForegroundColor(HSSFColor.BLUE_GREY.index);
   cellStyle.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);

   // 写入表头
   HSSFCell c;

   // String[] headerName = (String[]) aHeaderName.get(type);
   int[] maxLen = new int[4];
   int maxCol = list.size() + 3;
   ScoreRecordDetail first = list.get(0);
   Long scoreId = first.getScoreRecord().getScoreid();

   session = HibernateSessionFactory.getCurrentSession();

   ScoreSet scoreSet = (ScoreSet) session.createQuery("from ScoreSet where scoreid = :scoreid").setLong("scoreid",
     scoreId).uniqueResult();
   String titleName = scoreSet.getScoreLot().getLotName() + "-" + scoreSet.getScoreModel().getScoremodelname();
   //输出文g名落孙山
   String outFileName = scoreSet.getScoreModel().getScoremodelname();

   // 在表单中新徏0?br />    HSSFRow row0 = sheet1.createRow((short) 0);
   row0.setHeight((short) 600);
   c = row0.createCell((short) 0);
   HSSFCellStyle cellStyle0 = wb.createCellStyle();
   cellStyle0.setFont(font);// 单元格字?
   cellStyle0.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水^寚w方式
   cellStyle0.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

   cellStyle0.setBorderBottom(cellStyle.BORDER_THIN);// 单元D?br />    cellStyle0.setBorderTop(cellStyle.BORDER_THIN);
   cellStyle0.setBorderRight(cellStyle.BORDER_THIN);
   cellStyle0.setBorderLeft(cellStyle.BORDER_THIN);

   c.setCellStyle(cellStyle0);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue(titleName);// 单元格?br />    sheet1.addMergedRegion(new Region(0, (short) 0, 0, (short) (maxCol-1)));

   // 在表单中新徏1?br />    /**
   HSSFRow row1 = sheet1.createRow((short) 1);
   row1.setHeight((short) 700);
   c = row1.createCell((short) 0);
   HSSFCellStyle cellStyle1 = wb.createCellStyle();
   cellStyle1.setAlignment(HSSFCellStyle.ALIGN_LEFT); // 水^寚w方式
   cellStyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

   cellStyle1.setBorderBottom(cellStyle.BORDER_THIN);// 单元D?br />    cellStyle1.setBorderTop(cellStyle.BORDER_THIN);
   cellStyle1.setBorderRight(cellStyle.BORDER_THIN);
   cellStyle1.setBorderLeft(cellStyle.BORDER_THIN);

   c.setCellStyle(cellStyle1);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue("评标专家{֭Q?);// 单元格?/span>

   c = row1.createCell((short) 1);
   c.setCellStyle(cellStyle1);// 单元格的样式

   c = row1.createCell((short) 2);
   c.setCellStyle(cellStyle1);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue("日期Q?);// 单元格?/span>

   c = row1.createCell((short) 3);
   c.setCellStyle(cellStyle1);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   c.setCellValue(sdf.format(new Date()));// 单元格?br />             */
   // 在表单中新徏2?br />    HSSFRow row2 = sheet1.createRow((short) 1);
   row2.setHeight((short) 600);

   HSSFCellStyle cellStyle2 = wb.createCellStyle();
   cellStyle2.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水^寚w方式
   cellStyle2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
   cellStyle2.setFillBackgroundColor(HSSFColor.AQUA.index);

   cellStyle2.setBorderBottom(cellStyle.BORDER_THIN);// 单元D?br />    cellStyle2.setBorderTop(cellStyle.BORDER_THIN);
   cellStyle2.setBorderRight(cellStyle.BORDER_THIN);
   cellStyle2.setBorderLeft(cellStyle.BORDER_THIN);

   
   
   c = row2.createCell((short) 0);
   c.setCellStyle(cellStyle2);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue("专家名称");// 单元格?br />    /*****************************************************************/
   sheet1.addMergedRegion(new Region(1, (short) 0, 1, (short) 1));
   //sheet1.addMergedRegion(new Region(2, (short) 0, 2, (short) 1));
   /*****************************************************************/

   row2.setHeight((short) 400);
   c = row2.createCell((short) 1);
   c.setCellStyle(cellStyle2);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   //c.setCellValue("目");// 单元格?/span>

   row2.setHeight((short) 400);
   c = row2.createCell((short) 2);
   c.setCellStyle(cellStyle2);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue("分?);// 单元格?/span>

   //c = row2.createCell((short) 3);
   //c.setCellStyle(cellStyle2);// 单元格的样式
   
   //重复?br />    int rows=0;
   if(hashMap!=null){
    int j=0;
    
    HSSFRow[]  row_repeat= null;
    for (Iterator iterator = hashMap.values().iterator(); iterator.hasNext();) {
     Map map= (LinkedHashMap) iterator.next();     
     rows =map.size();
     row_repeat=new HSSFRow[map.size()];
     for(int i=0;i<rows;i++){
      /****************************************************/
      row_repeat[i] = sheet1.createRow((short) (2+i));
      //row_repeat[i] = sheet1.createRow((short) (3+i));
      /****************************************************/
      row_repeat[i].setHeight((short) 400);      
     }
     break;
    }
    
    for (Iterator iterator = hashMap.values().iterator(); iterator.hasNext();) {
     Map map= (LinkedHashMap) iterator.next();     
     int i=0;
     for (Iterator iter_key = map.keySet().iterator(); iter_key.hasNext();) {
      SysUser sysUser = (SysUser) iter_key.next();
      if(j==0){
       c = row_repeat[i].createCell((short) 0);
       c.setCellStyle(cellStyle2);// 单元格的样式
       c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
       c.setCellValue(sysUser.getUsername());// 单元格?br />        /******************************************************************/
       sheet1.addMergedRegion(new Region(2+i, (short) 0, 2+i, (short) 1));
       //sheet1.addMergedRegion(new Region(3+i, (short) 0, 3+i, (short) 1)); 
       /******************************************************************/
       
       c = row_repeat[i].createCell((short) 1);
       c.setCellStyle(cellStyle2);// 单元格的样式
  
       c = row_repeat[i].createCell((short) 2);
       c.setCellStyle(cellStyle2);// 单元格的样式
       c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
       c.setCellValue("40");// 单元格?br />       }
      
      c = row_repeat[i].createCell((short) (3+j));      
      c.setCellStyle(cellStyle2);// 单元格的样式
      c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);//数字?br />       c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
      
      c.setCellValue(Double.parseDouble(map.get(sysUser).toString()));// 单元格?nbsp;     
      i++;
     }
     
     j++;
    }
   }

   // 在表单中新徏3?br />    /************************************************/
   HSSFRow row3 = sheet1.createRow((short) (2+rows));
   //HSSFRow row3 = sheet1.createRow((short) (3+rows));
   /************************************************/
   row3.setHeight((short) 400);

   c = row3.createCell((short) 0);
   c.setCellStyle(cellStyle2);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue(scoreSet.getScoreModel().getScoremodelname() + " 评分");// 单元格?br />    /******************************************************************************/
   //sheet1.addMergedRegion(new Region((3+rows), (short) 0,(3+rows), (short) 1));
   sheet1.addMergedRegion(new Region((2+rows), (short) 0,(2+rows), (short) 1));
   /******************************************************************************/

   c = row3.createCell((short) 1);
   c.setCellStyle(cellStyle2);// 单元格的样式

   c = row3.createCell((short) 2);
   c.setCellStyle(cellStyle2);// 单元格的样式
   c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
   c.setCellValue("40");// 单元格?/span>


   for (int i = 0; i < list.size(); i++) {

    sheet1.setColumnWidth((short) (i + 3), (short) 5000);

    ScoreRecordDetail o = list.get(i);
    String name = "";
    if (o.getDevelopid() != null) {
     BasDevelop basDevelop = (BasDevelop) session.createQuery("from BasDevelop where developid = :developid")
       .setLong("developid", o.getDevelopid()).uniqueResult();
     name = basDevelop.getDename();
    } else {
     ProductType productType = (ProductType) session.createQuery("from ProductType where productid = :productid")
       .setLong("productid", o.getProductid()).uniqueResult();
     name = productType.getProdname();
    }
/****************************************************************************/
    //c = row1.createCell((short) (i + 3));
    //c.setCellStyle(cellStyle1);// 单元格的样式
/****************************************************************************/

    c = row2.createCell((short) (i + 3));
    c.setCellStyle(cellStyle2);// 单元格的样式
    c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
    c.setCellValue(name);// 单元格?/font>

    c = row3.createCell((short) (i + 3));
    c.setCellStyle(cellStyle2);// 单元格的样式
    c.setEncoding(HSSFCell.ENCODING_UTF_16);// ~码
    c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);//数字?br />     c.setCellValue(o.getScore());// 单元格?br />    }

   // 输出Excel文g
   errorOrExportExcel(response, wb, 2 ,outFileName);

  } catch (Exception e) {
   e.printStackTrace();
  }
  return false;
 }
 //l束
/***************************************************************************************************************/
}


]]>
点击表头排序[整理ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256088.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:25:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256088.htmlhttp://www.aygfsteel.com/1504/comments/256088.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256088.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256088.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256088.html?】这个非常好用,
<head>
<script type="text/javascript" src="sortabletable.js"></script>
<link type="text/css" rel="StyleSheet" href="sortabletable.css" />
</head>
?lt;head></head>之间加入
??lt;table class="sort-table" id="table-1" cellspacing="0">
要排序的表中要加?id="table-1"
??lt;thead>
  <tr>
   <td>String</td>
   <td title="CaseInsensitiveString">String</td>
   <td>Number</td>
   <td>Date</td>
   <td>No Sort</td>
  </tr>
</thead>
点击的表头之间加?lt;thead></thead>
剩下的之间加?lt;tbody></tbody>
<tbody>
  <tr>
   <td>apple</td>
   <td>Strawberry</td>
   <td>45</td>
   <td>2001-03-13</td>
   <td>Item 0</td>
  </tr>
  <tr>
   <td>Banana</td>
   <td>orange</td>
   <td>7698</td>
   <td>1789-07-14</td>
   <td>Item 1</td>
  </tr>
  <tr>
   <td>orange</td>
   <td>Banana</td>
   <td>4546</td>
   <td>1949-07-04</td>
   <td>Item 2</td>
  </tr>
 </tbody>
??/span>
</table>
<script type="text/javascript">
var st1 = new SortableTable(document.getElementById("table-1"),
 ["String", "CaseInsensitiveString", "Number", "Date", "None"]);


]]>
JAVA四舍五入(数点后保留两位数字)[自己ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256087.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:23:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256087.htmlhttp://www.aygfsteel.com/1504/comments/256087.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256087.html#Feedback1http://www.aygfsteel.com/1504/comments/commentRss/256087.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256087.htmlpublic String getFourToFive(double score_type)
 {
  double bl=(Math.round(score_type/.01)*.01);
  String st=String.valueOf(bl);
  /**注意,q里?作ؓ分隔W是失效?不知道ؓ什?所以采用替换的办法*/
  st=st.replace(".", "_");
  String []st_arr=st.split("_");
  String temp="";
  if(st_arr[1].length()>2)
  {
   temp=st_arr[1].substring(0, 2);
  }
  else
  if(st_arr[1].length()<2)
  {
   temp=st_arr[1]+"0";
  }
  else
  {
   temp=st_arr[1];
  }
  return st_arr[0]+"."+temp;
 }


weesun一c阳?/a> 2009-02-22 19:23 发表评论
]]>
实际目中用到的工厂模式[自己ȝ]http://www.aygfsteel.com/1504/archive/2009/02/22/256086.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:22:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256086.htmlhttp://www.aygfsteel.com/1504/comments/256086.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256086.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256086.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256086.html1.ExcelManagerFactory
package com.factory;

public class ExcelManagerFactory {
   private static String key = "key";
   private ExcelManagerFactory() {
   }
  
   private static ExcelManagerIf instance = null;
   public static ExcelManagerIf getInstance(){
    if(instance == null){
             synchronized(key){
                 if(instance == null){
                     instance = new ExcelManagerImpl();
                 }
             }
         }
         return instance;
   }
}

2.声明一个接?/span>

package com.factory;

import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.gpdi.orm.object.ScoreRecordDetail;

public interface ExcelManagerIf {
 
 public boolean export(HttpServletResponse response, List<ScoreRecordDetail> list,LinkedHashMap hashMap);
 /********************************************************************************************************/
 public boolean export1(HttpServletResponse response,List list,LinkedHashMap hashMap);
 /********************************************************************************************************/

 

}
3.实现接口的类


package com.factory;

import java.io.IOException;

 


public class ExcelManagerImpl implements ExcelManagerIf
{
         public boolean export1(HttpServletResponse response, List list,LinkedHashMap hashMap)
         {
                    //实现具体功能的代码实?br />          }
}
4.调用
  HttpServletResponse response=null;
  LinkedHashMap hm = new LinkedHashMap();
  List list = Object.getList();
   ExcelManagerIf eem = ExcelManagerFactory.getInstance();
   /******************************************************************/
   eem.export(response, list,hm);

 



]]>
Collection-用几行代码实现排序[转]http://www.aygfsteel.com/1504/archive/2009/02/22/256085.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:20:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256085.htmlhttp://www.aygfsteel.com/1504/comments/256085.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256085.html#Feedback1http://www.aygfsteel.com/1504/comments/commentRss/256085.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256085.html阅读全文

]]>
Apache+Tomcat负蝲均衡集群【整理备用?/title><link>http://www.aygfsteel.com/1504/archive/2009/02/22/256084.html</link><dc:creator>weesun一c阳?/dc:creator><author>weesun一c阳?/author><pubDate>Sun, 22 Feb 2009 11:20:00 GMT</pubDate><guid>http://www.aygfsteel.com/1504/archive/2009/02/22/256084.html</guid><wfw:comment>http://www.aygfsteel.com/1504/comments/256084.html</wfw:comment><comments>http://www.aygfsteel.com/1504/archive/2009/02/22/256084.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/1504/comments/commentRss/256084.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/1504/services/trackbacks/256084.html</trackback:ping><description><![CDATA[<p><font size="2">因ؓ很多目中会用到Apache+Tomcat负蝲均衡和集,最q研I了一下,心得留下,以备后用?br /> <a href="/Files/1504/apache_tomcat.rar">/Files/1504/apache_tomcat.rar</a><br /> <br /> 2010-03-28重新整理</font></p> <img src ="http://www.aygfsteel.com/1504/aggbug/256084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/1504/" target="_blank">weesun一c阳?/a> 2009-02-22 19:20 <a href="http://www.aygfsteel.com/1504/archive/2009/02/22/256084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate多对多双向关联映【{帖?/title><link>http://www.aygfsteel.com/1504/archive/2009/02/22/256083.html</link><dc:creator>weesun一c阳?/dc:creator><author>weesun一c阳?/author><pubDate>Sun, 22 Feb 2009 11:17:00 GMT</pubDate><guid>http://www.aygfsteel.com/1504/archive/2009/02/22/256083.html</guid><wfw:comment>http://www.aygfsteel.com/1504/comments/256083.html</wfw:comment><comments>http://www.aygfsteel.com/1504/archive/2009/02/22/256083.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/1504/comments/commentRss/256083.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/1504/services/trackbacks/256083.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;">转自Qhttp://blog.csdn.net/thinkGhoster/archive/2007/10/24/1841584.aspx<br />          Hibernate多对多双向关联映?</span> <p><span style="font-size: 10pt;">1、数据库l构</span></p> <p><span style="font-size: 10pt;">       category表:{ categoryId , categoryName }</span></p> <p><span style="font-size: 10pt;">       item表:{ itemId , itemName }</span></p> <p><span style="font-size: 10pt;">       category_item表:{ idCategory , idItem}</span></p> <p><span style="font-size: 10pt;">2、Category.hbm.xml</span></p> <div style="border-left-color: windowtext; padding-top: 4px; padding-right: 5.4pt; padding-bottom: 4px; padding-left: 5.4pt; background-image: none; background-repeat: repeat; background-attachment: scroll; background-color: #e6e6e6; width: 95%; background-position: 0% 0%; "> <div><span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff;"><</span><span style="color: #800000;">hibernate-mapping</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />    </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">class </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="com.persistent.Category"</span><span style="color: #ff0000;"> table</span><span style="color: #0000ff;">="category"</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">id </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="id"</span><span style="color: #ff0000;"> column</span><span style="color: #0000ff;">="categoryId"</span><span style="color: #ff0000;"> unsaved-value</span><span style="color: #0000ff;">="null"</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />            </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">generator </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="increment"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">generator</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">id</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="name"</span><span style="color: #ff0000;"> column</span><span style="color: #0000ff;">="categoryName"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">property</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">set </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="items"</span><span style="color: #ff0000;"> table</span><span style="color: #0000ff;">="category_item"</span><span style="color: #ff0000;"> cascade</span><span style="color: #0000ff;">="all"</span><span style="color: #ff0000;"> lazy</span><span style="color: #0000ff;">="false"</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />            </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">key </span><span style="color: #ff0000;">column</span><span style="color: #0000ff;">="idCategory"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">key</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />            </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">many-to-many </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="com.persistent.Item"</span><span style="color: #ff0000;"> column</span><span style="color: #0000ff;">="idItem"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">many-to-many</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">set</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />    </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">class</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">hibernate-mapping</span><span style="color: #0000ff;">></span></span></div> </div> <p><span style="font-size: 10pt;">3、Item.hbm.xml</span></p> <div style="border-left-color: windowtext; padding-top: 4px; padding-right: 5.4pt; padding-bottom: 4px; padding-left: 5.4pt; background-image: none; background-repeat: repeat; background-attachment: scroll; background-color: #e6e6e6; width: 95%; background-position: 0% 0%; "> <div><span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff;"><</span><span style="color: #800000;">hibernate-mapping</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />    </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">class </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="com.persistent.Item"</span><span style="color: #ff0000;"> table</span><span style="color: #0000ff;">="item"</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">id </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="id"</span><span style="color: #ff0000;"> column</span><span style="color: #0000ff;">="itemId"</span><span style="color: #ff0000;"> unsaved-value</span><span style="color: #0000ff;">="null"</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />            </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">generator </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="increment"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">generator</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">id</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">property </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="name"</span><span style="color: #ff0000;"> column</span><span style="color: #0000ff;">="itemName"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">property</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">set </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="categories"</span><span style="color: #ff0000;"> table</span><span style="color: #0000ff;">="category_item"</span><span style="color: #ff0000;"> lazy</span><span style="color: #0000ff;">="false"</span><span style="color: #ff0000;"> inverse</span><span style="color: #0000ff;">="true"</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />            </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">key </span><span style="color: #ff0000;">column</span><span style="color: #0000ff;">="idItem"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">key</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />            </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"><</span><span style="color: #800000;">many-to-many </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="com.persistent.Category"</span><span style="color: #ff0000;"> column</span><span style="color: #0000ff;">="idCategory"</span><span style="color: #0000ff;">></</span><span style="color: #800000;">many-to-many</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />        </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">set</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />    </span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">class</span><span style="color: #0000ff;">></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></span></span><span style="font-size: 10pt;"><span style="color: #0000ff;"></</span><span style="color: #800000;">hibernate-mapping</span><span style="color: #0000ff;">></span></span></div> </div> <p><span style="font-size: 10pt;">4、Category.java和Item.java</span></p> <div style="border-left-color: windowtext; padding-top: 4px; padding-right: 5.4pt; padding-bottom: 4px; padding-left: 5.4pt; background-image: none; background-repeat: repeat; background-attachment: scroll; background-color: #e6e6e6; width: 95%; background-position: 0% 0%; "> <div><span style="font-size: 10pt;"><img id="_22_102_Open_Image" style="display: inline;" onclick="this.style.display='none'; document.getElementById('_22_102_Open_Text').style.display='none'; document.getElementById('_22_102_Closed_Image').style.display='inline'; document.getElementById('_22_102_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_22_102_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_22_102_Closed_Text').style.display='none'; document.getElementById('_22_102_Open_Image').style.display='inline'; document.getElementById('_22_102_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> Category </span><span id="_22_102_Closed_Text" style="border: 1px solid #808080; display: none; background-color: #ffffff;">...</span></span><span id="_22_102_Open_Text" style="display: inline;"><span style="font-size: 10pt;"><span style="color: #000000;">{    <br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #0000ff;">private</span></span><span style="font-size: 10pt;"><span style="color: #000000;"> Long id;<br /> </span><span style="color: #0000ff;">    private</span></span><span style="font-size: 10pt;"><span style="color: #000000;"> String name;<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #0000ff;">private</span><span style="color: #000000;"> Set items </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span></span><span style="color: #000000;"><span style="font-size: 10pt;"> HashSet();<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />...<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /><br /> <img id="_123_207_Open_Image" onclick="this.style.display='none'; document.getElementById('_123_207_Open_Text').style.display='none'; document.getElementById('_123_207_Closed_Image').style.display='inline'; document.getElementById('_123_207_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="_123_207_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_123_207_Closed_Text').style.display='none'; document.getElementById('_123_207_Open_Image').style.display='inline'; document.getElementById('_123_207_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" /></span></span><span style="font-size: 10pt;"><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> Item </span><span id="_123_207_Closed_Text" style="border: 1px solid #808080; display: none; background-color: #ffffff;">...</span></span><span id="_123_207_Open_Text"><span style="font-size: 10pt;"><span style="color: #000000;">{<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #0000ff;">private</span></span><span style="font-size: 10pt;"><span style="color: #000000;"> Long id;<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #0000ff;">private</span></span><span style="font-size: 10pt;"><span style="color: #000000;"> String name;<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #0000ff;">private</span><span style="color: #000000;"> Set categories </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span></span><span style="color: #000000;"><span style="font-size: 10pt;"> HashSet();<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />...<br /> <img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></span><span style="color: #000000;"><br /> <span style="font-size: 10pt;"><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />    </span></span></div> </div> <p><span style="font-size: 10pt;">      映射文g中还可以不用set而用bagQ只要把set出现的地Ҏ成bagpQ这L应的category.java和Item.java</span></p> <p><span style="font-size: 10pt;">文g当中可以用List?/span></p> <img src ="http://www.aygfsteel.com/1504/aggbug/256083.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/1504/" target="_blank">weesun一c阳?/a> 2009-02-22 19:17 <a href="http://www.aygfsteel.com/1504/archive/2009/02/22/256083.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>getOutputStream() has already been called for this response的解冟뀐自己ȝ?http://www.aygfsteel.com/1504/archive/2009/02/22/256082.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:17:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256082.htmlhttp://www.aygfsteel.com/1504/comments/256082.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256082.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256082.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256082.html1.在项目中JSP面输出显CZؓ囄ӞhӞ报以下错?br /> getOutputStream() has already been called for this response
index.jsp

<HTML>
<HEAD>
<TITLE></TITLE>

</HEAD>

<BODY>
<TABLE>
<TR>
<TD></TD>
</TR>
<TR>
<TD><img src="show.jsp"></TD>
</TR>
</TABLE>

</BODY>
</HTML>


show.jsp
<%@ page contentType="text/html; charset=gbk" %>
<%@ page import="java.io.*"%>
<%@ page import="cn.com.hnisi.visio.image.*"%>
<%
VisioDemo v=new VisioDemo();
v.setVisible(false);
try
{
 byte[] image = v.getVisio().createPreview(new File("E:/test/test.vsd"));
 response.setContentType("image/jpeg");
 OutputStream outs = response.getOutputStream();
 outs.write(image);
 outs.flush();

}
catch(Exception e)
{
    System.out.println(e.getMessage());
}
%>
出现错误原因是response的数据流没有释放
解决办法
<%@ page contentType="text/html; charset=gbk" %>
<%@ page import="java.io.*"%>
<%@ page import="cn.com.hnisi.visio.image.*"%>
<%
VisioDemo v=new VisioDemo();
v.setVisible(false);
try
{
 byte[] image = v.getVisio().createPreview(new File("E:/test/test.vsd"));
 response.setContentType("image/jpeg");
 OutputStream outs = response.getOutputStream();
 outs.write(image);
 outs.flush();
 outs=null;
    response.flushBuffer();
    out.clear();
    out = pageContext.pushBody();

}
catch(Exception e)
{
    System.out.println(e.getMessage());
}
%>


]]>
使用displayQ关于取出列?http://www.aygfsteel.com/1504/archive/2009/02/22/256080.htmlweesun一c阳?/dc:creator>weesun一c阳?/author>Sun, 22 Feb 2009 11:16:00 GMThttp://www.aygfsteel.com/1504/archive/2009/02/22/256080.htmlhttp://www.aygfsteel.com/1504/comments/256080.htmlhttp://www.aygfsteel.com/1504/archive/2009/02/22/256080.html#Feedback0http://www.aygfsteel.com/1504/comments/commentRss/256080.htmlhttp://www.aygfsteel.com/1504/services/trackbacks/256080.html              <display:column    title="题目" sortable="true"  style="width: 15%" media="html">
                <ww:property value="#attr.row.ATTENTION_EVENT"/>&nbsp;
             </display:column>
</table>
通过   <ww:property value="#attr.row.ATTENTION_EVENT"/>可以实现取出列倹{注意:#attr为必,row?nbsp;<display:table >的属性id的倹{?

]]>
վ֩ģ壺 Ӣɳ| | | | Ԫ| | | | | | | | | Į| | ɽ| | | ˳| Ϸ| | ɽ| ˷| Ӧñر| ƽ| | | | | | | | | | | Դ| | | ľ| ϳ| ɽ|