??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产另类精品专区,久久国产欧美精品,久久视频一区二区http://www.aygfsteel.com/wangxinsh55/category/14223.htmlzh-cnThu, 27 Oct 2011 13:51:33 GMTThu, 27 Oct 2011 13:51:33 GMT60Spring事务配置的五U方?/title><link>http://www.aygfsteel.com/wangxinsh55/archive/2011/10/27/362165.html</link><dc:creator>SIMONE</dc:creator><author>SIMONE</author><pubDate>Thu, 27 Oct 2011 06:31:00 GMT</pubDate><guid>http://www.aygfsteel.com/wangxinsh55/archive/2011/10/27/362165.html</guid><wfw:comment>http://www.aygfsteel.com/wangxinsh55/comments/362165.html</wfw:comment><comments>http://www.aygfsteel.com/wangxinsh55/archive/2011/10/27/362165.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wangxinsh55/comments/commentRss/362165.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wangxinsh55/services/trackbacks/362165.html</trackback:ping><description><![CDATA[     摘要: 原来来自Qhttp://www.aygfsteel.com/robbie/archive/2009/04/05/264003.html    前段旉对Spring的事务配|做?jin)比较深入的研究Q在此之间对Spring的事务配|虽说也配置q,但是一直没有一个清楚的认识。通过q次的学?fn)发觉Spring的事务配|只要把思\理清Q还是比较好掌握的?  &n...  <a href='http://www.aygfsteel.com/wangxinsh55/archive/2011/10/27/362165.html'>阅读全文</a><img src ="http://www.aygfsteel.com/wangxinsh55/aggbug/362165.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wangxinsh55/" target="_blank">SIMONE</a> 2011-10-27 14:31 <a href="http://www.aygfsteel.com/wangxinsh55/archive/2011/10/27/362165.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts2 标签中的调用EnumҎ(gu)或调用内部类中的?rn)态方?/title><link>http://www.aygfsteel.com/wangxinsh55/archive/2011/08/24/357191.html</link><dc:creator>SIMONE</dc:creator><author>SIMONE</author><pubDate>Wed, 24 Aug 2011 06:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/wangxinsh55/archive/2011/08/24/357191.html</guid><wfw:comment>http://www.aygfsteel.com/wangxinsh55/comments/357191.html</wfw:comment><comments>http://www.aygfsteel.com/wangxinsh55/archive/2011/08/24/357191.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wangxinsh55/comments/commentRss/357191.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wangxinsh55/services/trackbacks/357191.html</trackback:ping><description><![CDATA[<div><div>com.duxiu.mobile.dao.web.WapRuleConfigDaoq个Z个类QCustomPage是com.duxiu.mobile.dao.web.WapRuleConfigDaocM的Enum或是内部c,则Struts2标签中调用的Ҏ(gu)如下Q?/div><s:property value="@com.duxiu.mobile.dao.web.WapRuleConfigDao$CustomPage@login.value" /></div><img src ="http://www.aygfsteel.com/wangxinsh55/aggbug/357191.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wangxinsh55/" target="_blank">SIMONE</a> 2011-08-24 14:48 <a href="http://www.aygfsteel.com/wangxinsh55/archive/2011/08/24/357191.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>历史上关于struts2 遍历Map最全的ȝhttp://www.aygfsteel.com/wangxinsh55/archive/2010/09/21/332623.htmlSIMONESIMONETue, 21 Sep 2010 09:56:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2010/09/21/332623.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/332623.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2010/09/21/332623.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/332623.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/332623.htmlStruts2中iterator标签遍历mapȝ

针对以下几种情况的Map:

  •     private Map<String,String> map;   
  •       
  •     private Map<String,Student> studentMap;   
  •        
  •     private Map<String,String[]> arrayMap;   
  •        
  •     private Map<String,List<Student>> listMap;

  •  


  •         map=new HashMap<String,String>();   
  •         map.put("1""one");   
  •         map.put("2""two");   
  • 用法Q?/p>

  •    <s:iterator value="map" id="column">   
  •    <s:property value="#column"/><br>   
  •    key: <s:property value="key"/><br>   
  •    value:<s:property value="value"/><br>  
  •   </s:iterator>   
  •  


  •         studentMap=new HashMap<String,Student>();   
  •         studentMap.put("student1",new Student(new Long(1),"20034140201","张三1","?,25));   
  •         studentMap.put("student2",new Student(new Long(2),"20034140202","张三2","?,26));   
  •         studentMap.put("student3",new Student(new Long(3),"20034140202","张三3","?,27));    
  • 用法Q?/p>

     

  •     <s:iterator value="studentMap" id="column">   
  •     <tr>   
  •      <td><s:property value="#column"/></td>   
  •      <td><s:property value="value.id"/></td>   
  •      <td><s:property value="value.num"/></td>   
  •      <td><s:property value="value.name"/></td>   
  •      <td><s:property value="value.sex"/></td>   
  •      <td><s:property value="value.age"/></td>   
  •     </tr>   
  •     </s:iterator> 
  •  


  •         arrayMap=new HashMap<String,String[]>();   
  •         arrayMap.put("arr1"new String[]{"1","2003401","leejie","male","20"});   
  •         arrayMap.put("arr2"new String[]{"2","2003402","huanglie","male","25"});   
  •         arrayMap.put("arr3"new String[]{"3","2003403","lixiaoning","male","21"});   
  •            
  • 用法

     

  •     <s:iterator value="arrayMap" id="column">   
  •     <tr>   
  •      <td><s:property value="#column"/></td>   
  •      <td><s:property value="value[0]"/></td>   
  •      <td><s:property value="value[1]"/></td>   
  •      <td><s:property value="value[2]"/></td>   
  •      <td><s:property value="value[3]"/></td>   
  •      <td><s:property value="value[4]"/></td>   
  •     </tr>   
  •     </s:iterator>  
  •  


  •            
  •         listMap=new HashMap<String,List<Student>>();   
  •            
  •         List<Student> list1=new ArrayList<Student>();   
  •         list1.add(new Student(new Long(1),"20034140201","张三1","?,25));   
  •         list1.add(new Student(new Long(2),"20034140202","张三2","?,25));   
  •         list1.add(new Student(new Long(3),"20034140203","张三3","?,25));   
  •         listMap.put("class1", list1);   
  •            
  •         List<Student> list2=new ArrayList<Student>();   
  •         list2.add(new Student(new Long(1),"20034140301","李四1","?,20));   
  •         list2.add(new Student(new Long(2),"20034140302","李四2","?,21));   
  •         list2.add(new Student(new Long(3),"20034140303","李四3","?,22));   
  •         list2.add(new Student(new Long(4),"20034140304","李四4","?,23));   
  •         listMap.put("class2", list2);   
  •  

    用法Q?/p>

  •    <s:iterator value="listMap" id="column">   
  •      <s:set name="total" value="#column.value.size"/>   
  •      <s:iterator value="#column.value" status="s">   
  •       <tr>   
  •         <s:if test="#s.first"><td rowspan="${total}"><s:property value="#column.key"/></td></s:if>   
  •         <td><s:property value="id"/></td>   
  •         <td><s:property value="num"/></td>   
  •         <td><s:property value="name"/></td>   
  •         <td><s:property value="sex"/></td>   
  •         <td><s:property value="age"/></td>   
  •       </tr>   
  •      </s:iterator>   
  •   </s:iterator>  


  • SIMONE 2010-09-21 17:56 发表评论
    ]]>
    SpringSide 3 中的多数据源配置的问?/title><link>http://www.aygfsteel.com/wangxinsh55/archive/2010/02/25/313859.html</link><dc:creator>SIMONE</dc:creator><author>SIMONE</author><pubDate>Thu, 25 Feb 2010 02:27:00 GMT</pubDate><guid>http://www.aygfsteel.com/wangxinsh55/archive/2010/02/25/313859.html</guid><wfw:comment>http://www.aygfsteel.com/wangxinsh55/comments/313859.html</wfw:comment><comments>http://www.aygfsteel.com/wangxinsh55/archive/2010/02/25/313859.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wangxinsh55/comments/commentRss/313859.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wangxinsh55/services/trackbacks/313859.html</trackback:ping><description><![CDATA[     摘要: 在SpringSide 3 中,白衣提供的预先配|好的环境非常有利于用户q行快速开发,但是同时也会(x)为扩展带来一些困难。最直接的例子就是关于在目中用多个数据源的问题,g 很难搞。在上一中Q我探讨?jin)SpringSide 3 中的数据讉K层,在这一中Q我立志要解军_数据源配|的NQ我的思\是这L(fng)Q? W一步、测试能否配|多个DataSource W二步、测试能否配|多个Sessi...  <a href='http://www.aygfsteel.com/wangxinsh55/archive/2010/02/25/313859.html'>阅读全文</a><img src ="http://www.aygfsteel.com/wangxinsh55/aggbug/313859.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wangxinsh55/" target="_blank">SIMONE</a> 2010-02-25 10:27 <a href="http://www.aygfsteel.com/wangxinsh55/archive/2010/02/25/313859.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>S2SH 框架 Zannotation配置http://www.aygfsteel.com/wangxinsh55/archive/2010/02/24/313835.htmlSIMONESIMONEWed, 24 Feb 2010 14:06:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2010/02/24/313835.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/313835.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2010/02/24/313835.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/313835.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/313835.html阅读全文

    SIMONE 2010-02-24 22:06 发表评论
    ]]>
    struts2+spring发送mailhttp://www.aygfsteel.com/wangxinsh55/archive/2009/05/15/270872.htmlSIMONESIMONEFri, 15 May 2009 08:27:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2009/05/15/270872.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/270872.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2009/05/15/270872.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/270872.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/270872.html

      spring中有集成?jin)javamailQ在使用框架的时候用spring来发送mail也是很方便的。下面是一个spring mail的小例子?/p>

      在这个例子中Q除?jin)需要struts和spring的框架外Q还需要mail.jar,activation.jar.

      web.xml的代码:(x)

      <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4"
     xmlns="  xmlns:xsi="  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:spring/*.xml</param-value>
     </context-param>

     <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
        <!-- Spring refresh Introspector to prevent from out of memory  -->
     <listener>
      <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
     </listener>
     <!-- Support session scope, Spring bean -->
     <listener>                                                       
          <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
     </listener>
     <!-- Struts2 Action Mapping-->
     <filter>
            <filter-name>struts2</filter-name>
            <filter-class>
                org.apache.struts2.dispatcher.FilterDispatcher
            </filter-class>
        </filter>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
       <!-- session time out -->
     <session-config>
      <session-timeout>30</session-timeout>
     </session-config>
     <!-- default index -->
     <welcome-file-list>
      <welcome-file>send.jsp</welcome-file>
     </welcome-file-list>
    </web-app>
    JavacMailAction.java:

    package action;

    import org.springframework.mail.SimpleMailMessage;
    import org.springframework.mail.javamail.JavaMailSenderImpl;

    import com.opensymphony.xwork2.Action;
    import com.opensymphony.xwork2.ActionSupport;
    public class MailAction extends ActionSupport{
     private JavaMailSenderImpl mailSender;
     private SimpleMailMessage mailMessage;
      public String sendMail(){
      SimpleMailMessage msg = new SimpleMailMessage(mailMessage);
            msg.setText("Spring Mail Simple!");
            mailSender.send(msg);
            return Action.SUCCESS;
     }
      public void setMailMessage(SimpleMailMessage mailMessage) {
      this.mailMessage = mailMessage;
     }

     public void setMailSender(JavaMailSenderImpl mailSender) {
      this.mailSender = mailSender;
     }

    }
    spring配置文gapplicationContext.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="
        xmlns:xsi="     xmlns:aop="     xmlns:tx="     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
               http://www.springframework.org/schema/tx     default-autowire="byName" default-lazy-init="true">

     <bean id="mailAction" class="action.MailAction">
      <property name="mailSender" ref="mailSender"/>
      <property name="mailMessage" ref="mailMessage"/>
     </bean>
     
     <bean id="mailSender"
              class="org.springframework.mail.javamail.JavaMailSenderImpl">
            <property name="host" value="smtp.163.com"/>
                <!-- mail  account   -->
            <property name="username" value="shwwwx"/>
            <property name="password" value="wwx1226"/>
            <property name="javaMailProperties">
                <props>
                    <prop key="mail.smtp.auth">true</prop>
                </props>
            </property>
        </bean>
          <!-- mail template -->
        <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
            <property name="to" value="
    shwwwx@163.com,nabelun@163.com"/>
            <property name="from" value="shwwwx@163.com"/>
            <property name="subject" value="Mail Simple"/>
        </bean>
    </beans>

    struts2的配|文件struts.xml:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        " <struts>
        <constant name="struts.objectFactory" value="spring" />
        <constant name="struts.devMode" value="false" />
        <constant name="struts.i18n.encoding" value="utf-8" />
        <package name="springtimer"   extends="struts-default">
           <action name="mailsend" class="mailAction" method="sendMail">
            <result>sendok.jsp</result>
            <interceptor-ref name="defaultStack"/>
           </action>
        </package>
    </struts>
    面send.jsp:

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <html>
      <head>
        <title>My JSP 'send.jsp' starting page</title>
      </head>
      <body>
     <form action="mailsend.action" method="post">
      <input type="submit" value="邮g发?>
     </form>
      </body>
    </html>

    面sendok.jsp:

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>My JSP 'sendok.jsp' starting page</title>
      </head>
      <body>
        Send Mail Success! <br>
      </body>
    </html>
    q行send.jsp发送邮Ӟ成功的话?x)蟩转到sendok.jsp面?/p>

    SIMONE 2009-05-15 16:27 发表评论
    ]]>
    struts2中二l数l的昄http://www.aygfsteel.com/wangxinsh55/archive/2009/02/24/256486.htmlSIMONESIMONETue, 24 Feb 2009 09:50:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2009/02/24/256486.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/256486.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2009/02/24/256486.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/256486.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/256486.html

    1、用两重循环的方?/p>

    <s:iterator id="data1" value="#request.data" status="d1">
    <s:iterator id="data2" value="#request.data1" status="d2">
    <s:property value="#data2"/>
    </s:iterator>
    </s:iterator>

    2、用一重@环的Ҏ(gu)

    <s:iterator value="collection1" status="status">
    <s:property value="collection1[#status.index][0]"/>
    <s:property value="collection1[#status.index][1]"/>
    </s:iterator> 



    SIMONE 2009-02-24 17:50 发表评论
    ]]>
    Struts AjaxTagshttp://www.aygfsteel.com/wangxinsh55/archive/2006/11/22/82757.htmlSIMONESIMONEWed, 22 Nov 2006 06:10:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2006/11/22/82757.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/82757.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2006/11/22/82757.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/82757.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/82757.htmlFrank W. Zammetti扩展?jin)Struts的Tag库,使Struts具备?jin)AJAX功能?
          Q注Q下面的代码引用?strong>Frank W. Zammetti 的ajaxtags包)(j)
     
          Tag库的扩展
          1、FormTag
               增加?jin)refAjax属性以?qing)setter和getterҎ(gu)Q?/div>
          2、BaseHandlerTag
               增加?jin)refAjax属性以?qing)setter和getterҎ(gu)Q?/div>
               同时扩展?jin)prepare×××EventsҎ(gu)Q其加载Ajax属性,如:(x)
               if (getOnkeydown() != null) {
                      ......
               }
               /* Frank W. Zammetti */
               else {
                      prepareAjax("onkeydown", handlers);
               }
               /* Frank W. Zammetti */
          3、Struts-Html.tld
               增加?jin)refAjax属性;
     
          应用
          1、ajax-config.xml
               ......
               <form ajaxRef="example1">
                    <element ajaxRef="button">
                          <event type="onclick">
                                //发送请求的讄
                                <requestHandler type="std:QueryString">
                                     <target>example1.do</target>
                                     <parameter>firstName=firstName,lastName=lastName</parameter>
                                </requestHandler>
                                //回调函数Q方法)(j)?qing)回写区域的讄?br />                            <responseHandler type="std:InnerHTML">
                                     <parameter>example1_resultLayer</parameter>
                                </responseHandler>
                          </event>
                    </element>
               </form>
               ......
          2、struts-config.xml
               ......
               //与其它Action的区别是QAjax调用的Action没有input和forward
               <action path="/example1" name="example1Form" scope="request"
                                 type="com.omnytex.ajaxtags.Example1Action" />
               ......
               //Ajax Tag Plugin
               <plug-in className="org.apache.struts.taglib.html.ajax.AjaxInit" />
               ......
          3、Jsp客户界面
               ......
               //对应于ajax-config.xml中的form ajaxRef
               <html:form action="example1" ajaxRef="example1">
                    ......
                    //对应于ajax-config.xml中的Element ajaxRef
                    <html:button property="button" value="Click to do Ajax!" ajaxRef="button" />
               </html:form>
               Result:<br>
               //对应于ajax-config.xml中的responseHandler
               <span id="example1_resultLayer">&nbsp;</span>
               ......
               //启用AjaxQ应该放在Jsp的最后)(j)
               <html:enableAjax />
               ......
          4、Action
               ......
               public ActionForward execute( ...... ) throws Exception {
                    try {
                        ......
                        //Ajax的Action需要输出内容到out
                        PrintWriter out = response.getWriter();
                        out.println(......);
                        out.flush();
                        out.close();
                    } catch (Exception e) {
                        System.err.println("Exception in Example1Action.execute(): " + e);
                    }
                    //׃Ajax的Action输出的内容由面的区域接Ӟ不需要蟩转到其它面
                    //所以,q回null
                    return null;
               }
               ......
     
          Struts Ajax Tag工作原理
          1、Struts启动Q加载AjaxInitQ?/div>
          2、AjaxInit解析ajax-config.xmlQ?/div>
          3、Struts加蝲AjaxEnabled的JspQ?/div>
          4、Struts-AjaxTagҎ(gu)Form ajaxRef和elment ajaxRef扑ֈajax-config的设|;
          5、输出AjaxEnabled的HtmlQTag库加入了(jin)Ajax需要的ScriptQ如QXMLHttpRequestQ;
          6、用戯入数据,提交数据Q异步模式提交后Q用户可以l其它操作)(j)Q?/div>
          7、XMLHttpRequest对象接管提交数据Qƈ向Struts提交do?qing)参敎ͼ?/div>
          8、Struts ActionServlet加蝲FormBeanQ和相应的ActionQ?/div>
          9、Struts Action执行相应逻辑Q得到返回的数据Q通过out输出Q?/div>
          10、XMLHttpRequest得到Strutsq回的数据;
          11、XMLHttpRequest调用讄的回调函敎ͼҎ(gu)Q,输出数据到指定的区域Q?/div>

    SIMONE 2006-11-22 14:10 发表评论
    ]]>Struts下拉菜单对应昄(getDirectLabelValueBean )http://www.aygfsteel.com/wangxinsh55/archive/2006/11/16/81439.htmlSIMONESIMONEThu, 16 Nov 2006 01:44:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2006/11/16/81439.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/81439.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2006/11/16/81439.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/81439.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/81439.html2006-10-31 19:55

    ****************************************************************************************************************

    DAO里面如下写:(x)

    package com.sinoconcept.match.dao.impl;

    import java.util.List;

    import org.springframework.dao.DataAccessException;

    import com.sinoconcept.match.dao.DirctDAO;

    public class DirctDAOImpl extends BaseDAOHibernateImpl implements DirctDAO {

     public List loadAll(String className) {
      
      try {
       return this.getHibernateTemplate().loadAll(Class.forName(className));
      } catch (DataAccessException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      } catch (ClassNotFoundException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
      return null;
     }

    }

    ***************************************************************************************************************

    service里如下写Q?/strong>

    package com.sinoconcept.match.service.impl;

    import java.lang.reflect.InvocationTargetException;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;

    import org.apache.struts.util.LabelValueBean;

    import com.sinoconcept.match.dao.DirctDAO;
    import com.sinoconcept.match.service.DirctService;

    public class DirctServiceImpl implements DirctService {
     private DirctDAO dirctDAO;

     public List getDirect(String dirName) {

      List result = this.getDir(dirName);
      return result;
     }

     public List getDirectLabelValueBean(String dirName) {

      List result = this.getDirLableValueBean(dirName);
      return result;
     }

     public List getDir(String dirName) {
      List result = null;

      result = dirctDAO.loadAll(dirName);

      return result;
     }

     @SuppressWarnings("unchecked")
     public List getDirLableValueBean(String dirName) {
      List result = new LinkedList();
      List list = getDir(dirName);
      I(yng)terator it = list.iterator();
      while (it.hasNext()) {
       Object obj = it.next();
       LabelValueBean lv = new LabelValueBean();
       String label = null;
       try {
        label = obj.getClass().getMethod("getName", new Class[] {})
          .invoke(obj, null).toString();
       } catch (Exception e) {
        try {
         label = obj.getClass()
           .getMethod("getValue", new Class[] {}).invoke(obj,
             null).toString();
        } catch (IllegalArgumentException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
        } catch (SecurityException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
        } catch (IllegalAccessException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
        } catch (InvocationTargetException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
        } catch (NoSuchMethodException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
        }
       } finally {
        if (label == null)
         try {
          label = label = obj.getClass().getMethod("getValue",
            new Class[] {}).invoke(obj, null).toString();
         } catch (IllegalArgumentException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (SecurityException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (IllegalAccessException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (InvocationTargetException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (NoSuchMethodException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         }
       }
       lv.setLabel(label);
       try {
        lv.setValue(obj.getClass().getMethod("getId", new Class[] {})
          .invoke(obj, null).toString());
       } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       }
       result.add(lv);
      }
      return result;
     }

     public DirctDAO getDirctDAO() {
      return dirctDAO;
     }

     public void setDirctDAO(DirctDAO dirctDAO) {
      this.dirctDAO = dirctDAO;
     }

    }

    ***********************************************************************************************************************

    Action里面如下讄Q?/p>

    String status = request.getParameter("status");
      if (status == null || status.equals("")) {
       status = "0";
      }

    List sttusList = dirctService
        .getDirectLabelValueBean("com.sinoconcept.match.domain.DrStatus");//数据字典?/strong>

    //DrStatus 数据映设文g只要二个字段Qprivate Integer idQprivate String value;

    manDiaryForm.setStatus(status);

    request.setAttribute("statusList", sttusList);

    ****************************************************************************************************************

    面上如下获得:(x)

    <html:select property="status" onchange="sel()">
           <html:optionsCollection name="statusList" />
          </html:select>



    SIMONE 2006-11-16 09:44 发表评论
    ]]>Struts Validation框架尝2http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64197.htmlSIMONESIMONEThu, 17 Aug 2006 11:51:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64197.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/64197.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64197.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/64197.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/64197.html javascript 支持

           ?/span> web 应用中,使用 javascript 的机?x)非常多。虽然不书上提?qing)客h可能从浏览器关闭 js 的执行,但是要想完全的不使用它,目前看来好像q不行。比如一些复杂的 UI 是必通过 js 来实现的Q如下拉式菜单等{)(j)。那?/span> validation 框架支不支持客户端的 js 验证呢?

    {案是:(x)当然。具体做法是Q?/span>

    -          在页?/span> html:form 标签内部d onsubmit="return validateEditForm(this);" Q具体的语法Q?/span> validate+ ?/span> validation.xml 文g中定义的 form 的名字)(j)Q如Q?/span>

    <html:form action="<%=action%>" method="post" onsubmit="return validateEditForm(this);">

    -          ?/span> html:form 内部块中dQ?/span> <html:javascript formName="editForm"/>

           如此 2 步即可。虽?dng)?/span> validation 框架非常单易用,但是q是有需要注意的地方?/span>

    使用注意

    1.       使用 validation 框架后, form 必须?/span> ValidatorForm 中派生,同时必须在你?/span> validate Ҏ(gu)中先调用基类?/span> validate Ҏ(gu)。对于?/span> Dyna 开头的Ҏ(gu)来创?/span> formbean 的读者,你也必须改ؓ(f)?/span> dyna 开头含?/span> validator ?/span> form ?/span>

    2.       注意 DynaValidatorForm Q?/span> ValidatorForm Q和 DynaValidatorActionForm Q?/span> ValidatorActionForm Q的区别。刚开始时从帮助中没看明白q?/span> 2 者的区别Q后来从|上一文章中得到?jin)用法的区别。前者主要的视角?/span> formbean Q而后者的视角?/span> action ?/span>

    ?/span> formbean 被不同的 action 使用Ӟ对于不同?/span> action 而言Q用的 formbean 的属性集合有大有。此时如果仍然以 formbean Z体,?x)造成其他 action 的不正常使用。因此, struts 中提Z(jin) DynaValidatorActionForm Q?/span> ValidatorActionForm Q。此时在 validation.xml 中的 form 标签?/span> name 属性改?/span> action ?/span> path 属性,又由?/span> action 中有 attribute ?/span> name 属性, validation 框架可Ҏ(gu)q个 action 得到对应?/span> formbean 。例子:(x)

    <formset>

      <form name="/createAddress">

        <field property="city"

              depends="required">

          <arg0 key="prompt.city"/>

        </field>

      </form>

      <form name="/editAddress">

        <field property="state"

              depends="required">

          <arg0 key="prompt.state"/>

        </field>

      </form>

    </formset>

    3.       ?/span> DispatchAction 的配合?/span> Struts1.1 ?/span> DispatchAction 使得相关?/span> Action 的关pȝ密,大大减少?jin)应用?/span> Action 的个敎ͼ但是随之而来也带来了(jin)使用 Validation 框架的不便,不能不说是一个遗憾。读者也许认U情况可以用第 2 条的解决Ҏ(gu)来解冻I即采?/span> DyanValidatorActionForm Q然后在 Validation.xml 文g?/span> form 的名UC用不同的 Actiond ?/span> path Q即?/span> validation.xml 中用:(x) <form name="/user.do?method=doAdd"> ?/span>     <form name="/user.do?method=doLoad"> 。然而,在目前的版本?/span> Validation 框架q不支持q种辨认。一U绕q这个情늚Ҏ(gu)是,针对同一?/span> Action 实现cd Struts-config.xml 文g中定义多?/span> Action ?/span> path Q在不需要进行验证的地方?/span> Action ?/span> validate 属性置?/span> false 。即Q?/span>

    struts-config.xml Q?/span>

    <action attribute="editForm" path="/user" name="editForm" input="/editUser.jsp"

    parameter="method" scope="request" type="foxgem.struts.UserDispatchAction"

         validate="true">

                   <forward name="load" path="/editUser.jsp"/>

                   <forward name="action" path="/userquery.do?pageId=1"/>

    </action>

           

    <action attribute="editForm" path="/loaduser" name="editForm" input="/editUser.jsp"

              parameter="method" scope="request" type="foxgem.struts.UserDispatchAction"

              validate="false">

                   <forward name="load" path="/editUser.jsp"/>

                   <forward name="action" path="/userquery.do?pageId=1"/>

    </action>

    然后?/span> validation.xml 文g中?/span> 2 的方法?/span>

    l束?/font>

           ȝ说来Q?/span> validation 框架大大的提高了(jin)面验证的开发效率,更吸引h的是q些验证Ҏ(gu)可通过自定义的 validator 来得到复用。得这些验证代码更加集中,可维护性得到加强。当焉着目的进行, validation.xml ?/span> validator-rules.xml ?x)随之增长,q部分的l护工作加重?jin)?/span>

           同时Q由于不能非常好的和 DispatchAction 一起协作,也得大量?/span> DispatchAction 的项目不能非常好的用它。徏议大量?/span> DispatchAction 和页面验证非常复杂多变的目可以暂时按原来的Ҏ(gu)来验证,不?/span> validation 框架?/span>

           至于 validation 框架的其他详l信息,请参?/span> struts 的文档,在此不再赘述?/span>

    参考资?/font>

    n         http://raibledesigns.com/wiki/Wiki.jsp?page=SecuringDispatchAction DispatchAction ?/span> validation 框架的协作解x案来源于此?/span>

    n         http://otn.oracle.com/oramag/oracle/04-jan/o14dev_struts.html Check Your Form with Validator

    n         http://www-900.ibm.com/developerWorks/cn/java/l-struts1-1/ 深入 Struts 1.1

    n         http://javaboutique.internet.com/tutorials/Struts11Val/ Stepping through the Struts 1.1 Validator



    SIMONE 2006-08-17 19:51 发表评论
    ]]>
    Struts Validator验证器用指?/title><link>http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64191.html</link><dc:creator>SIMONE</dc:creator><author>SIMONE</author><pubDate>Thu, 17 Aug 2006 11:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64191.html</guid><wfw:comment>http://www.aygfsteel.com/wangxinsh55/comments/64191.html</wfw:comment><comments>http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64191.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wangxinsh55/comments/commentRss/64191.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wangxinsh55/services/trackbacks/64191.html</trackback:ping><description><![CDATA[     摘要: 作者:(x) David Winterfeldt 大卫 James Turner 詹姆? Rob Leland |伯? 译Q?        侯思超 验证器:(x) ...  <a href='http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64191.html'>阅读全文</a><img src ="http://www.aygfsteel.com/wangxinsh55/aggbug/64191.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wangxinsh55/" target="_blank">SIMONE</a> 2006-08-17 19:32 <a href="http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64191.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts、spring、hibernate中文q问题解决 http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64185.htmlSIMONESIMONEThu, 17 Aug 2006 11:01:00 GMThttp://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64185.htmlhttp://www.aygfsteel.com/wangxinsh55/comments/64185.htmlhttp://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64185.html#Feedback0http://www.aygfsteel.com/wangxinsh55/comments/commentRss/64185.htmlhttp://www.aygfsteel.com/wangxinsh55/services/trackbacks/64185.html       q日Q用struts 1.1Q发现讨厌的中文q问题Q在form的传送过E和入库时候出现。就我在|络上找的方法罗列如下:(x)
    QTomcat 5.0.28+struts 1.1+hibernate 2.1+sqlserver2kQ?br />1.直接转编码public static String isoToGB(String src){   
    String strRet=null;   
    try{    
      strRet = new String(src.getBytes("ISO_8859_1"),"GB2312");  
      }catch(Exception e)    {         
    }    return strRet;
    }通过一个函数{~码Q我没有成功Q不知ؓ(f)何!

    2.qo(h)filter讄?br />
    package yourbean;

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;

    public class servfilter extends HttpServlet implements Filter {  private FilterConfig filterConfig;  //Handle the passed-in FilterConfig  public void init(FilterConfig filterConfig) {    this.filterConfig = filterConfig;  }  //Process the request/response pair  public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) {    try {      request.setCharacterEncoding("GB2312");       ((HttpServletResponse)response).setHeader("Cache-control","no-cache");      response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setHeader("Expires","0");       ((HttpServletResponse)response).setHeader("Pragram","no-cache");      filterChain.doFilter(request, response);    }    catch(ServletException sx) {      filterConfig.getServletContext().log(sx.getMessage());    }    catch(IOException iox) {      filterConfig.getServletContext().log(iox.getMessage());    }  }  //Clean up resources  public void destroy() {  }}下面是一个web.xml文g你用jbuilder写上面的bean的时候会(x)生成一?lt;?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"    "http://java.sun.com/dtd/web-app_2_3.dtd">

    <web-app>  <display-name>Welcome to Tomcat</display-name>  <description>     Welcome to Tomcat  </description>  <filter>    <filter-name>servfilter</filter-name>    <filter-class>yourbean.servfilter</filter-class>  </filter>  <filter-mapping>    <filter-name>servfilter</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping></web-app>把上面的servfilter~译攑֜你的web-inf/classes/yourbean/下web.xml攑֜web-inf/下和classes在一个目录下在每个jsp面上加?lt;%@page contentType="text/html;charset=GBK"%>

    也不是很方便Q而且在tomcat也没有成功,l箋郁闷Q?br />
    3.我现在用方法,推荐Q!

    写一个myActionServlet来ƈ覆盖ActionServlet中的processQ)(j)Ҏ(gu)?br />
      protected void process(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException {    /**@todo Override this org.apache.struts.action.ActionServlet method*/    request.setCharacterEncoding("GB2312");//加着一行一切都解决?jin)  ?super.process(request, response);  }

    当然别忘?jin)改一下web.xml里面的配|?<servlet>    <servlet-name>action</servlet-name>    <servlet-class>strutsdemo.myActionServlet</servlet-class>    <init-param>      <param-name>debug</param-name>      <param-value>2</param-value>    </init-param>    <init-param>      <param-name>config</param-name>      <param-value>/WEB-INF/struts-config.xml</param-value>    </init-param>    <load-on-startup>2</load-on-startup>  </servlet>

    改一下servlet-class标签中的内容可以!

    真的可以Q一劳用yiQ?br />
    具体~码的理论就不说?jin),google上已l够多了(jin)?br />
    另外Q如果不用struts的话Qhibernate也可能碰C文ؕ码问题,只要在hibernate.cfg.xml配置中如下:(x)

    <property name="hibernate.connection.url">   jdbc:microsoft:sqlserver://Localhost:1433;SelectMethod=cursor;characterEncoding=GBK;DatabaseName=myDatabase.  </property>

    characterEncoding=GBKQ就可以?jin)?br />


    ********************************************************************************************************************

    Java/J2EE中文问题l极解决之道

    Java中文问题一直困扰着很多初学者,如果?jin)解了(jin)Javapȝ的中文问题原理,我们可以对中文问题能够采取Ҏ(gu)的解决之道?

      最古老的解决Ҏ(gu)是用String的字节码转换Q这U方案问题是不方便,我们需要破坏对象封装性,q行字节码{换?/p>

      q有一U方式是对J2EE容器q行~码讄Q如果J2EE应用pȝq该容器,则会(x)发生qQ而且指定容器配置不符合J2EE应用和容器分ȝ原则?/p>

      在Java内部q算中,涉及(qing)到的所有字W串都会(x)被{化ؓ(f)UTF-8~码来进行运。那么,在被Java转化之前Q字W串是什么样的字W集Q?JavaLҎ(gu)操作pȝ的默认编码字W集来决定字W串的初始编码,而且Javapȝ的输入和输出的都是采取操作系l的默认~码?/p>

      因此Q如果能l一Javapȝ的输入、输出和操作pȝ3者的~码字符集合Q将能够使Javapȝ正确处理和显C汉字。这是处理Javapȝ汉字的一个原则,但是在实际项目中Q能够正抓住和控制住Javapȝ的输入和输出部分是比较难的。J2EE中,׃涉及(qing)到外部浏览器和数据库{,所以中文问题ؕ码显得非常突出?/p>

      J2EE应用E序是运行在J2EE容器中。在q个pȝ中,输入途径有很多种Q一U是通过面表单打包成请求(requestQ发往服务器的Q第二种是通过数据库读入;q有W?U输入比较复杂,JSP在第一ơ运行时L被编译成ServletQJSP中常常包含中文字W,那么~译使用javacӞJava根据默认的操作pȝ~码作ؓ(f)初始~码。除非特别指定,如在Jbuilder/eclipse中可以指定默认的字符集?/p>

      输出途径也有几种Q第一U是JSP面的输出。由于JSP面已经被编译成ServletQ那么在输出Ӟ也将Ҏ(gu)操作pȝ的默认编码来选择输出~码Q除非指定输出编码方式;q有输出途径是数据库Q将字符串输出到数据库?/p>

      由此看来Q一个J2EEpȝ的输入输出是非常复杂Q而且是动态变化的Q而Java是跨q_q行的,在实际编译和q行中,都可能涉?qing)到不同的操作系l,如果ȝJava自由Ҏ(gu)操作pȝ来决定输入输出的~码字符集,q将不可控制地出Cؕ码?/p>

      正是׃Java的跨q_Ҏ(gu),使得字符集问题必ȝ具体pȝ来统一解决Q所以在一个Java应用pȝ中,解决中文q的根本办法是明确指定整个应用pȝl一字符集?/strong>

      指定l一字符集时Q到底是指定ISO8859_1 、GBKq是UTF-8呢?

      Q?Q如l一指定为ISO8859_1Q因为目前大多数软g都是西方人编制的Q他们默认的字符集就是ISO8859_1Q包括操作系lLinux和数据库MySQL{。这P如果指定Jivel一~码为ISO8859_1Q那么就有下?个环节必L握:(x)

      开发和~译代码时指定字W集为ISO8859_1?/p>

      q行操作pȝ的默认编码必LISO8859_1Q如Linux?/p>

      在JSP头部声明Q?lt;%@ page contentType="text/html;charset=ISO8859_1" %>?/p>

      Q?Q如果统一指定为GBK中文字符集,上述3个环节同样需要做刎ͼ不同的是只能q行在默认编码ؓ(f)GBK的操作系l,如中文Windows?/p>

      l一~码为ISO8859_1和GBK虽然带来~制代码的方便,但是各自只能在相应的操作pȝ上运行。但是也破坏?jin)Java跨^台运行的优越性,只在一定范围内行得通。例如,Z(jin)使得GBK~码在linux上运行,讄Linux~码为GBK?/p>

      那么有没有一U除?jin)应用系l以外不需要进行Q何附加设|的中文~码Ҏ(gu)解决Ҏ(gu)呢?

      Java/J2EEpȝ的统一~码定义为UTF-8。UTF-8~码是一U兼Ҏ(gu)有语a的编码方式,惟一比较ȝ(ch)的就是要扑ֈ应用pȝ的所有出入口Q然后用UTF-8厠Z结扎”它?/p>

      一个J2EE应用pȝ需要做下列几步工作Q?/p>

    1. 开发和~译代码时指定字W集为UTF-8。JBuilder和Eclipse都可以在目属性中讄?
    2. 使用qo(h)器,如果所有请求都l过一个Servlet控制分配器,那么使用Servlet的filter执行语句Q将所有来自浏览器的请求(requestQ{换ؓ(f)UTF-8Q因为浏览器发过来的h包根据浏览器所在的操作pȝ~码Q可能是各种形式~码。关键一句:(x)
      request.setCharacterEncoding("UTF-8")?br />|上有此filter的源码,Jdon框架源码中com.jdon.util.SetCharacterEncodingFilter
      需要配|web.xml Ȁz该Filter?
    3. 在JSP头部声明Q?lt;%@ page contentType="text/html;charset= UTF-8" %>?
    4. 在Jsp的html代码中,声明UTF-8:
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    5. 讑֮数据库连接方式是UTF-8。例如连接MYSQL旉|URL如下Q?br />jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8
      一般数据库都可以通过理讄讑֮UTF-8
    6. 其他和外界交互时能够讑֮~码时就讑֮UTF-8Q例如读取文Ӟ操作XML{?
           

      以上讨论?jin)Java/J2EE的中文问题。如果整个应用系l是从开始进行开发,那么l一指定~码为UTF-8非常容易做到。如果是在英文源代码基础上二ơ开发,那么首先要将原来的源代码转换为统一~码UTF-8Q那么这U{换工作会(x)带来一定的ȝ(ch)?/p>  

      有了(jin)q个解决Ҏ(gu)Q无Z用什么框架Struts 或JSF或未来出现的Java技术,l一成UTF-8的方案都不会(x)出现qQ笔者以前在Jsp/Servlet时就Zq个原则Q后来用Struts{框Ӟ从未被ؕ码困扰过Q希望本Ҏ(gu)公布出来供更多初学者分享,减少Java/J2EE的第一个拦路虎Q也避免采取一些(f)时解x案?br />

    ***********************************************************************************************************************
      <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>  
      <init-param>  
      <param-name>forceEncoding</param-name>  
      <param-value>true</param-value>  
      </init-param>  
      </filter>  
       
                        <filter-mapping>  
      <filter-name>encodingFilter</filter-name>  
      <servlet-name>action</servlet-name>  
      </filter-mapping>


    ***********************************************************************************************

    hibernate+mysql写入数据库的中文?b style="COLOR: black; BACKGROUND-COLOR: #a0ffff">qQ怎么解决Q?


    hibernate.hbm.xml加上属?
    <property name=\"connection.useUnicode\">true</property>
    <property name=\"connection.characterEncoding\">UTF-8</property>

    mysql 的驱动用3.0.15以上版本?

    加个Filter, 使用UTF-8字符集就可以?


     


    1.使ApplicationResources.properties支持中文
    建立一个ApplicationResources_ISO.properties文gQ把应用E序用的message都写q去Q然后在dos下执行这个命令,
    native2ascii -encoding gb2312 ApplicationResources_ISO.properties ApplicationResources.properties
    q样׃(x)ISO~码的ApplicationResources转换成GB2312~码的格式了(jin)Q同时保存到ApplicationResources.properties.
    native2asciiq个工具是jdk自带的一个东东,所以如果path都设定正就可以直接q行?jin),你可以?java_home$/bin下找C?br />转换后的中文cM于这个样?br />iso 格式下 :(x)tj.type=商品车类?br />gb2312格式下 :(x)tj.type=\u5546\u54c1\u8f66\u7c7b\u578b
    然后在struts-config.xml中设|应用这个资源文?br /> <message-resources parameter=\"com.huahang.tj.ApplicationResources\" key=\"org.apache.struts.action.MESSAGE\" />
    开发jsp时在jsp的开头写?lt;%@ page contentType=\"text/html; charset=gb2312\" %>Q将字符集设|成gb2312可以了(jin)?br />
    2.使数据库操作支持中文?br />数据库操作支持中文一直让我比较头痛,但是感谢善解向我推荐?jin)www.chinaxp.orgQ这个网站是用struts框架开发的Q而且
    开放源码,下蝲?jin)源码后发现它的中文处理得很好,阅读部分源码Q没有发C么特D的字符集{换,很纳P偶然看到g|友
    留言知道原来servlet可以l一讄字符转换。chinaxp.org是q么做的?br />在web.xml中加?br />  <filter>
        <filter-name>Set Character Encoding</filter-name>
        <filter-class>com.huahang.tj.struts.filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
          <param-name>encoding</param-name>
          <param-value>GB2312</param-value>
        </init-param>
        <init-param>
          <param-name>ignore</param-name>
          <param-value>true</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>Set Character Encoding</filter-name>
        <servlet-name>action</servlet-name>
      </filter-mapping>
    q里?x)涉及(qing)一个bean,源码如下Q?br />/*
     * XP Forum
     *    
     * Copyright (c) 2002-2003 RedSoft Group.  All rights reserved.
     *
     */
    package com.huahang.tj.struts.filters;

    import javax.servlet.*;
    import java.io.IOException;

    /**
     * <p>Filter that sets the character encoding to be used in parsing the
     * incoming request, either unconditionally or only if the client did not
     * specify a character encoding.  Configuration of this filter is based on
     * the following initialization parameters:</p>
     * <ul>
     * <li><strong>encoding</strong> - The character encoding to be configured
     *     for this request, either conditionally or unconditionally based on
     *     the <code>ignore</code> initialization parameter.  This parameter
     *     is required, so there is no default.</li>
     * <li><strong>ignore</strong> - I(yng)f set to \"true\", any character encoding
     *     specified by the client is ignored, and the value returned by the
     *     <code>selectEncoding()</code> method is set.  I(yng)f set to \"false,
     *     <code>selectEncoding()</code> is called <strong>only</strong> if the
     *     client has not already specified an encoding.  By default, this
     *     parameter is set to \"true\".</li>
     * </ul>
     *
     * <p>Although this filter can be used unchanged, it is also easy to
     * subclass it and make the <code>selectEncoding()</code> method more
     * intelligent about what encoding to choose, based on characteristics of
     * the incoming request (such as the values of the <code>Accept-Language</code>
     * and <code>User-Agent</code> headers, or a value stashed in the current
     * user\'s session.</p>
     *
     * @author <a href=\"mailto:jwtronics@yahoo.com\">John Wong</a>
     *
     * @version $Id: SetCharacterEncodingFilter.java,v 1.1 2002/04/10 13:59:27 johnwong Exp $
     */
    public class SetCharacterEncodingFilter implements Filter {

        // ----------------------------------------------------- I(yng)nstance Variables


        /**
         * The default character encoding to set for requests that pass through
         * this filter.
         */
        protected String encoding = null;


        /**
         * The filter configuration object we are associated with.  I(yng)f this value
         * is null, this filter instance is not currently configured.
         */
        protected FilterConfig filterConfig = null;


        /**
         * Should a character encoding specified by the client be ignored?
         */
        protected boolean ignore = true;


        // --------------------------------------------------------- Public Methods


        /**
         * Take this filter out of service.
         */
        public void destroy() {

            this.encoding = null;
            this.filterConfig = null;

        }


        /**
         * Select and set (if specified) the character encoding to be used to
         * interpret request parameters for this request.
         *
         * @param request The servlet request we are processing
         * @param result The servlet response we are creating
         * @param chain The filter chain we are processing
         *
         * @exception I(yng)OException if an input/output error occurs
         * @exception ServletException if a servlet error occurs
         */
        public void doFilter(ServletRequest request, ServletResponse response,
                             FilterChain chain)
        throws I(yng)OException, ServletException {

            // Conditionally select and set the character encoding to be used
            if (ignore || (request.getCharacterEncoding() == null)) {
                String encoding = selectEncoding(request);
                if (encoding != null)
                    request.setCharacterEncoding(encoding);
            }

        // Pass control on to the next filter
            chain.doFilter(request, response);

        }


        /**
         * Place this filter into service.
         *
         * @param filterConfig The filter configuration object
         */
        public void init(FilterConfig filterConfig) throws ServletException {

        this.filterConfig = filterConfig;
            this.encoding = filterConfig.getInitParameter(\"encoding\");
            String value = filterConfig.getInitParameter(\"ignore\");
            if (value == null)
                this.ignore = true;
            else if (value.equalsIgnoreCase(\"true\"))
                this.ignore = true;
            else if (value.equalsIgnoreCase(\"yes\"))
                this.ignore = true;
            else
                this.ignore = false;

        }


        // ------------------------------------------------------ Protected Methods


        /**
         * Select an appropriate character encoding to be used, based on the
         * characteristics of the current request and/or filter initialization
         * parameters.  I(yng)f no character encoding should be set, return
         * <code>null</code>.
         * <p>
         * The default implementation unconditionally returns the value configured
         * by the <strong>encoding</strong> initialization parameter for this
         * filter.
         *
         * @param request The servlet request we are processing
         */
        protected String selectEncoding(ServletRequest request) {

            return (this.encoding);

        }

    }//EOC
    加上q个后,在action中就可以直接从form中接收gb2312~码的数据了(jin)Q返回时自然也是gb2312?jin)?br />但是q个好像需要servlet 2.2以上的容?br />
    l合上面的方法,我解决了(jin)struts中的中文问题Q现在还没发现新的问题?/font>



    SIMONE 2006-08-17 19:01 发表评论
    ]]>Struts常见异常信息和解x?/title><link>http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64183.html</link><dc:creator>SIMONE</dc:creator><author>SIMONE</author><pubDate>Thu, 17 Aug 2006 10:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64183.html</guid><wfw:comment>http://www.aygfsteel.com/wangxinsh55/comments/64183.html</wfw:comment><comments>http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64183.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wangxinsh55/comments/commentRss/64183.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wangxinsh55/services/trackbacks/64183.html</trackback:ping><description><![CDATA[ <p>以下所说的struts-config.xml和ApplicationResources.properties{文件名是缺省时使用的,如果你用了(jin)多模块,或指定了(jin)不同的资源文件名Uͼq些名字要做相应的修攏V?/p> <p> <strong>1、“No bean found under attribute key XXX?br /></strong>在struts-config.xml里定义了(jin)一个ActionFormQ但type属性指定的cM存在Qtype属性的值应该是Formcȝ全名。或者是Q在Action的定义中Qname或attribute属性指定的ActionForm不存在?br /></p> <p> <strong>2、“Cannot find bean XXX in any scope?/strong> <br />在Action里一般会(x)request.setAttribute()一些对象,然后在{向的jsp文g里(用tag或request.getAttribute()Ҏ(gu)Q得到这些对象ƈ昄出来。这个异常是说jsp要得C个对象,但前面的Action里ƈ没有对象设|到requestQ也可以是session、servletContextQ里?br />可能是名字错?jin),h查jsp里的tag的一般是name属性,或getAttribute()Ҏ(gu)的参数|或者是Action逻辑有问题没有执行setAttribute()Ҏ(gu)先转向?jin)?br />q有另外一个可能,Ua(b)是jsp文g的问题,例如<logic:iterate>?x)指定一个id|然后在@环里<bean:write>使用q个g为name的|如果q两个g同,也会(x)出现此异常。(都是一个道理,request里没有对应的对象。)(j)<br /></p> <p> <strong>3、“Missing message for key "XXX"?/strong> <br />~少所需的资源,(g)查ApplicationResources.properties文g里是否有jsp文g里需要的资源Q例如:(x)</p> <p> </p> <div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <div> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" align="top" /> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">bean:message key</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">msg.name.prompt</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">/></span> </div> </div> <p> </p> <p>q行代码?x)找msg.name.prompt资源Q如果AppliationResources.properties里没有这个资源就?x)出现本异常。在使用多模块时Q要注意在模块的struts-config-xxx.xml里指定要使用的资源文件名Uͼ否则当然什么资源也找不刎ͼq也是一个很Ҏ(gu)犯的错误?/p> <p> <strong>4、“No getter method for property XXX of bean teacher?/strong> <br />q条异常信息说得很明白,jsp里要取一个bean的属性出来,但这个beanq没有这个属性。你应该(g)查jsp中某个标{property属性的倹{例如下面代码中的cade应该改ؓ(f)code才对Q?/p> <div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <div> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" align="top" /> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">bean:write name</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">teacher</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000"> property</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">cade</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000"> filter</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">true</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">/></span> </div> </div> <br /> <p> </p> <p> <strong>5、“Cannot find ActionMappings or ActionFormBeans collection?br /></strong>待解冟?/p> <p> <strong>6、“Cannot retrieve mapping for action XXX?br /></strong>?jsp?lt;form>标签里指定action='/XXX'Q但q个Actionq未在struts-config.xml里设|过?/p> <p> <strong>7、HTTP Status 404 - /xxx/xxx.jsp<br /></strong>Forward的path属性指向的jsp面不存在,h查\径和模块Q对于同一模块中的Action转向Qpath中不应包含模块名Q模块间转向Q记住用contextRelative="true"?/p> <p> <strong>8、没有Q何异怿息,昄I白面</strong> <br />可能是Action里用的forward与struts-config.xml里定义的forward名称不匹配?br /></p> <p> <strong>9、“The element type "XXX" must be terminated by the matching end-tag "XXX".?br /></strong>q个是struts-config.xml文g的格式错误,仔细(g)查它是否是良构的xml文gQ关于xml文g的格式这里就不赘qC(jin)?/p> <p> <strong>10、“Servlet.init() for servlet action threw exception?/strong> <br />一般出现这U异常在后面?x)显CZ个关于ActionServlet的异常堆栈信息,其中指出?jin)异常具体出现在代码的哪一行。我曄遇到的一ơ提C如下:(x)</p> <div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <div> <img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" align="top" /> <span style="COLOR: #000000">java.lang.NullPointerException<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" align="top" />    at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:</span> <span style="COLOR: #000000">1003</span> <span style="COLOR: #000000">)<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" align="top" />    at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:</span> <span style="COLOR: #000000">955</span> <span style="COLOR: #000000">)<br /><img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" align="top" /><img src="http://www.cnblogs.com/Images/dot.gif" onload="var image=new Image();image.src=this.src;if(image.width>0 && image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" /></span> </div> </div> <p> <br />决问题,先下载struts的源码包Q然后在ActionServlet.java的第1003行插入断点,q对各变量进行监视。很丢hQ我竟然把struts-config.xml文g弄丢?jin),因此出现了(jin)上面的异常Q应该是和CVS同步时不心(j)删除的?/p> <p> <strong>11、“Resources not defined for Validator?/strong> <br />q个是利用Validator插g做验证时可能出现的异常,q时你要(g)查validation.xml文gQ看里面使用的资源是否确实有定义Qform的名U是否正,{等?/p> <p>上面q些是我在用Struts做项目时遇到q的问题Q其中一些曾困绕我不时_(d)其实大部分都是自׃l心(j)造成的。希望这文章能对你的开发有所帮助QƈƢ迎l箋补充?br /><br />12.<span id="wmqeeuq" class="top_title">Struts~译中出现“cannot find actionmappings or actionformbeans collection”提C的原因Q?br /></span></p> <ol> <li>Web.xml未初始化问题<br />了(jin)一?lt;load-on-startup>0</load-on-startup><br />q样开始是没有加蝲q个c,没有初始化struts-config.xmlQ所以找不到<br />actionmappings or actionformbeans collection?br /></li> <li>struts-config.xml问题<br /></li> <li>jar包不全或版本不对<br />也有可能Dq个问题Q从stuts例子里面拯来就好了(jin)。struts1.1自带?0个jar包?br /></li> <li>~译问题<br />有可能Action和Formbean没有~译Q也?x)有q个问题Q检查一下有没有对应的class文g好。class路径不对可能也会(x)Dq个问题?br /></li> <li>版本问题<br />用的servlet容器和struts版本不对或这两个版本协调有问题?br />在以上几条都不能解决问题的情况下Q可能就是版本的问题?jin),换个高版本试试?/li> </ol> <img src ="http://www.aygfsteel.com/wangxinsh55/aggbug/64183.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wangxinsh55/" target="_blank">SIMONE</a> 2006-08-17 18:57 <a href="http://www.aygfsteel.com/wangxinsh55/archive/2006/08/17/64183.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">º</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">ȫ</a>| <a href="http://" target="_blank">ϵ</a>| <a href="http://" target="_blank">ľ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϸ</a>| <a href="http://" target="_blank">°Ͷ</a>| <a href="http://" target="_blank">ղ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ٲ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƶ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>