??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久99爱,粉嫩精品一区二区三区在线观看,国产二区在线播放http://www.aygfsteel.com/beauty_beast/archive/2006/06/24/54840.html柳随?/dc:creator>柳随?/author>Sat, 24 Jun 2006 02:59:00 GMThttp://www.aygfsteel.com/beauty_beast/archive/2006/06/24/54840.htmlhttp://www.aygfsteel.com/beauty_beast/comments/54840.htmlhttp://www.aygfsteel.com/beauty_beast/archive/2006/06/24/54840.html#Feedback1http://www.aygfsteel.com/beauty_beast/comments/commentRss/54840.htmlhttp://www.aygfsteel.com/beauty_beast/services/trackbacks/54840.html阅读全文

]]>
Spring框架学习二篇?---在WEBMVC学习遇到的问?/title><link>http://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48086.html</link><dc:creator>柳随?/dc:creator><author>柳随?/author><pubDate>Thu, 25 May 2006 10:10:00 GMT</pubDate><guid>http://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48086.html</guid><wfw:comment>http://www.aygfsteel.com/beauty_beast/comments/48086.html</wfw:comment><comments>http://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48086.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/beauty_beast/comments/commentRss/48086.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/beauty_beast/services/trackbacks/48086.html</trackback:ping><description><![CDATA[ <p>q两天在学习SpringMVC遇到两个比较郁闷的问题,估计新学者很Ҏ遇到Q和大家分n一下,避免出现cM的问题?br />1?No request handling method with name 'insert' in class  "ClassName"Q页面显CZؓ404错误<br />q个问题出现在用多操作控制器情况下Q相关的操作Ҏ中对应的Ҏ参数前两位必Lrequest,response对象Q必要有,否则会报如上异常?br />2、这个问题困惑了我半天,在网上也有类似的问题Q但没有正确解决ҎQ异常如下:<br />javax.servlet.ServletException: ModelAndView [ModelAndView: materialized View is [null]<br />q个问题可能出现的场景很多,我所描述的只是其中之一Q没有相兌x法,只有查看相关源代码,开源就是有q个好处?br />异常抛出代码为:<br />        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:924)<br />查看了相x代码Q一层一层看下去<br />首先在ModelAndView cd例是在DispatcherServletcM的doDispatchҎ中创建的Q?br />再跟tdoDispatchҎ中相关代码行<br /></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">HandlerAdapter ha </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> getHandlerAdapter(mappedHandler.getHandler());<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />mv </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> ha.handle(processedRequest, response, mappedHandler.getHandler());<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span> </div> <p>ha是一个接口实现类Q在该场景下Q对应的接口实现cMؓQ?br />org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter<br /><br />SimpleControllerHandlerAdaptercM对应的实C码ؓQ?/p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">((Controller) handler).handleRequest(request, response)</span> </div> <p>调用的是对应的Controller接口中方法,当前Controller对应的接口实现类为我们配|的自定义控制类Q一般承于org.springframework.web.servlet.mvc.SimpleFormController;一层一层再跟踪发现Q?br />SimpleFormControllerl层于同包AbstractFormControllerc,?br />AbstractFormControllerl承于同包AbstractControllerc,对应?br />handleRequest(request,response)在AbstractControllercM实现Q最l调用代码如下:<br /></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000"> handleRequestInternal(request, response)</span> </div> <p>handleRequestҎZ个抽象方法,在AbstractFormControllercM实现Q终于找到原因了Q呵?br /></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">protected</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">final</span> <span style="COLOR: #000000"> ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)<br /><img id="Codehighlighter1_129_1027_Open_Image" onclick="this.style.display='none'; Codehighlighter1_129_1027_Open_Text.style.display='none'; Codehighlighter1_129_1027_Closed_Image.style.display='inline'; Codehighlighter1_129_1027_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_129_1027_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_129_1027_Closed_Text.style.display='none'; Codehighlighter1_129_1027_Open_Image.style.display='inline'; Codehighlighter1_129_1027_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />            </span> <span style="COLOR: #0000ff">throws</span> <span style="COLOR: #000000"> Exception </span> <span id="Codehighlighter1_129_1027_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.aygfsteel.com/images/dot.gif" /> </span> <span id="Codehighlighter1_129_1027_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> Form submission or new form to show?</span> <span style="COLOR: #008000"> <br /> <img id="Codehighlighter1_207_926_Open_Image" onclick="this.style.display='none'; Codehighlighter1_207_926_Open_Text.style.display='none'; Codehighlighter1_207_926_Closed_Image.style.display='inline'; Codehighlighter1_207_926_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_207_926_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_207_926_Closed_Text.style.display='none'; Codehighlighter1_207_926_Open_Image.style.display='inline'; Codehighlighter1_207_926_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" /> </span> <span style="COLOR: #000000">        </span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000"> (isFormSubmission(request)) </span> <span id="Codehighlighter1_207_926_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.aygfsteel.com/images/dot.gif" /> </span> <span id="Codehighlighter1_207_926_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> Form submission: in session-form mode, we need to find<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> the form object in the HTTP session.</span> <span style="COLOR: #008000"> <br /> <img id="Codehighlighter1_338_625_Open_Image" onclick="this.style.display='none'; Codehighlighter1_338_625_Open_Text.style.display='none'; Codehighlighter1_338_625_Closed_Image.style.display='inline'; Codehighlighter1_338_625_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_338_625_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_338_625_Closed_Text.style.display='none'; Codehighlighter1_338_625_Open_Image.style.display='inline'; Codehighlighter1_338_625_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" /> </span> <span style="COLOR: #000000">            </span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000"> (isSessionForm()) </span> <span id="Codehighlighter1_338_625_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.aygfsteel.com/images/dot.gif" /> </span> <span id="Codehighlighter1_338_625_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                HttpSession session </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> request.getSession(</span> <span style="COLOR: #0000ff">false</span> <span style="COLOR: #000000">);<br /><img id="Codehighlighter1_488_620_Open_Image" onclick="this.style.display='none'; Codehighlighter1_488_620_Open_Text.style.display='none'; Codehighlighter1_488_620_Closed_Image.style.display='inline'; Codehighlighter1_488_620_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_488_620_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_488_620_Closed_Text.style.display='none'; Codehighlighter1_488_620_Open_Image.style.display='inline'; Codehighlighter1_488_620_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000"> (session </span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">||</span> <span style="COLOR: #000000"> session.getAttribute(getFormSessionAttributeName(request)) </span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000">) </span> <span id="Codehighlighter1_488_620_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.aygfsteel.com/images/dot.gif" /> </span> <span id="Codehighlighter1_488_620_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> Cannot submit a session form if no form object is in the session.</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">                    </span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000"> handleInvalidSubmit(request, response);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> Found form object in HTTP session: fetch form object,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> bind, validate, process submission.</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">            Object command </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> getCommand(request);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            ServletRequestDataBinder binder </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> bindAndValidate(request, command);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000"> processFormSubmission(request, response, command, binder.getErrors());<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> <br /> <img id="Codehighlighter1_936_1024_Open_Image" onclick="this.style.display='none'; Codehighlighter1_936_1024_Open_Text.style.display='none'; Codehighlighter1_936_1024_Closed_Image.style.display='inline'; Codehighlighter1_936_1024_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_936_1024_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_936_1024_Closed_Text.style.display='none'; Codehighlighter1_936_1024_Open_Image.style.display='inline'; Codehighlighter1_936_1024_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span> <span style="COLOR: #0000ff">else</span> <span style="COLOR: #000000"> </span> <span id="Codehighlighter1_936_1024_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.aygfsteel.com/images/dot.gif" /> </span> <span id="Codehighlighter1_936_1024_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> New form to show: render form view.</span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">            </span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000"> showNewForm(request, response);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />    }</span> </span> </div> <p>原因实际很简单,因为我在要提交的表单中没有采用postҎQ呵?br />而isFormSubmission(request)是Ҏ此项判断Q所以其实际执行的代码ؓQ?br />return showNewForm(request, response);<br />而我在对应的配置属性中没有配置对应属?formView|因ؓ我本来就不是要展C个新表单?br />故最后返回的ModelAndView为空?br /><br />问题都解决了Q只是没惛_Ҏ交表单这么严|其他web框架是没有这U限Ӟ不过也没多大关系Q在实际开发中我们大都是采用post方式提交表单的?br /><br /></p> <img src ="http://www.aygfsteel.com/beauty_beast/aggbug/48086.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/beauty_beast/" target="_blank">柳随?/a> 2006-05-25 18:10 <a href="http://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48086.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring框架学习一----基本配置http://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48064.html柳随?/dc:creator>柳随?/author>Thu, 25 May 2006 08:39:00 GMThttp://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48064.htmlhttp://www.aygfsteel.com/beauty_beast/comments/48064.htmlhttp://www.aygfsteel.com/beauty_beast/archive/2006/05/25/48064.html#Feedback4http://www.aygfsteel.com/beauty_beast/comments/commentRss/48064.htmlhttp://www.aygfsteel.com/beauty_beast/services/trackbacks/48064.html         ׃两三天看了相x档,只是初步了解相关配置Q没有做深入了解Q才辑ֈ基本会用配|的目的?br />
个h理解Q?/strong>
         Spring 最基本的的功能是提供通过配置理Lc,提供了Bean理容器。这也是Spring最基础Q最核心的功能,在Spring框架中,一切皆为Bean,实际上在我们的日常开发中Q往往更多的是和Bean相关的开发,q且都是短生命周期,除了一些缓存功能,其他很多重要的功能都是由开源框架完成?br />        实现方式也是框架常用的反机?因此使用Spring前提在JVM启动参数中不能加安全理配置?br />        Spring中所有的Bean相关配置均ؓ一个文Ӟ非常集中Q个人感觉这有利有弊Q利大于弊?br />        l一配置比较方便集中Q我最q的目是有很多子pȝQ除了一些公用的配置文gQ还有很多子pȝ的配|文Ӟ每次q移环境是非常篏的事Q如果只有一个配|文Ӟ那工作就会轻村֤了?br />        ~点也就在于很集中,如果配置有误Q整个系l不可用Q这U情况往往发生在系l升U阶D,也比较少Q即使出现问题也比较好定位?br />         Spring提供了Bean理容器Q这个功能可以大大简化业务系l的配置开发工作?br />         个h感觉来的开发工作更多的是配|,~写业务相关的Bean以及业务Ҏ,其他功能均会有很多优U的开源框架实玎ͼ重要的工作是选择W合目的框架、熟悉框Ӟ最重要的还是苦修内功,深入学习javaQ因Z变不如其中,再说开源不是万能的Q有时候还是要靠自q?br />        

学习心得Q?br />Spring提供三种创徏cd例方?
    a、通过构造函敎ͼ讉K属性可以是L
    b、通过对应cȝ静态工厂方法,注意不能是私有的
     c、通过工厂cȝ实例工厂ҎQ是非静态的Ҏ

Q、bean节点相关主要属性:
     id/name          实例?别名
     class              必须、类全名
     singleton        是否为单实例Q默认ؓtrue
     init-method     初始化方?br />     depends-on    指定依赖Bean,实现在被依赖Bean实例创徏前,对依赖的一个或多个Bean的实例化, 
                           init-method在对应Bean实例已经创徏后调?br />     destroy-method   释放回调ҎQ常用于资源释放
     dependency-check 依赖?br />     parent           指定父Bean实例Q减因l承关系的重复配|?/p>

     说明除配|init-method,destory以外Q可以在对应Bean中实现InitializingBean,DisposableBean两个接口Ҏ
     Spring容器不负责管理非单实例的Bean

配置bean事项Q?br />1、注意在通过构造器参数匚wӞ必须指定参数的序P同时明确说明cdQ?br />  <constructor-arg index="0"><value>128</value></constructor-arg>
  <constructor-arg index="1"><value>teststring</value></constructor-arg> 
  最好说明相兛_数类型类型?
  <constructor-arg index="0" type="int"><value>128</value></constructor-arg>
  <constructor-arg index="1" type="java.lang.String"><value>teststring</value></constructor-arg> 
  可以使用化配|?br />  <constructor-arg index="0" type="int"  value="128"/>
  <constructor-arg index="1" type="java.lang.String" value="testString"/>
   
2、属性ؓI?br />    <property name="pro1><null/></property>
3、空?
    <property name="pro1><value></value></property>  

二、常用elements
bean | ref | idref | value | null | list | set | map | props

说明Q?br />     bean      创徏一个新的bean实例
     ref         引用已经创徏的bean实例
     value      单数据类?br />     null         I指?br />     list         创徏java.util.ArrayList对象实例
     set         创徏java.util.LinkedHashSet对象实例
     map       创徏java.util.LinkedHashMap对象实例
     props     创徏java.util.Properties实例   

list,set,map可以多层嵌套配置


遗留问题Q?br />idref 配置没有起作用,cMvalue配置Q测试输Zؓ字符串对象,是否配置不正?

上述配置范围基本覆盖了我们开发时的bean使用情况Q详见配|可以参考dtd
http://www.springframework.org/dtd/spring-beans.dtd


ApplicationContext l承于BeanFactory相关接口Q针对企业应用的,占有内存较多
BeanFactory     提供配置框架和基本功能,适用于对内存有限制的相关应用
功能Q?br />1、提供消息访问,ApplicationContext 本nl承于MessageSource接口Q?br />   ApplicationContext 加蝲时查扑֯应的MessageSource Bean, bean id 必须为messageSource
   Spring框架提供两个MessageResource实现Q?br />    org.springframework.context.support.ResourceBundleMessageSource
    org.springframework.context.support.StaticMessageSource
2、事件传?br />3、用资?br />



]]>
Spring框架学习前言---我的开源框架用心得体?/title><link>http://www.aygfsteel.com/beauty_beast/archive/2006/05/16/46421.html</link><dc:creator>柳随?/dc:creator><author>柳随?/author><pubDate>Tue, 16 May 2006 07:45:00 GMT</pubDate><guid>http://www.aygfsteel.com/beauty_beast/archive/2006/05/16/46421.html</guid><wfw:comment>http://www.aygfsteel.com/beauty_beast/comments/46421.html</wfw:comment><comments>http://www.aygfsteel.com/beauty_beast/archive/2006/05/16/46421.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.aygfsteel.com/beauty_beast/comments/commentRss/46421.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/beauty_beast/services/trackbacks/46421.html</trackback:ping><description><![CDATA[ <p> </p> <p> <strong>目的Q?/strong> <br />在实际项目中ZE_性以及团队开发技能我一直没考虑采用Spring框架Q最q有旉p划学习Spring框架Qؓ以后的项目开发做相关的技术储备?/p> <p> <br /> <strong>回顾Q?/strong> <br />开源框架在以前的项目中用过不少Q?struts,webwork,hibernate,前两者属于web框架Q后者属于ORM框架Q这些框架基本都是侧重于应用的某个层面,不能UC为J2EE全面的框Ӟ往往是需要和其他框架相结合,我开发的目采用q如下组合,有的Ҏ没有框Ӟ只是自己做了设计装<br />a、servlet+jdbc,<br />b、servlet+jsp+javabean+jdbc,<br />c、struts+BD+DAO ,<br />d、webwork+ejb+hibernate <br /><br /><strong>使用体会Q?/strong></p> <p> a、b׃要说了,那时候的代码l构真是天马行空Q我当时初学Q维护公怸个项目代码,1个jsp实现一个模块所有功能,我花了好长时间才 L代码?br />  时代L向前发展的,慢慢的系l结构层ơ上是越来越清晰Q开发效率也来高Q维护也来容易(Z一定的培训成本Q?br /> <br /><font color="#6666ff"> 相对而言Z设计理念来讲Q个人更喜欢webwork+hibernate框架l合?/font> <br /><br /> 常有论同{开发层面框架的优缺点,我所属品的另外一个项目团队曾lؓ目后箋开?应该采用strutsq是webwork争论的不可开交, 其实个h认ؓstruts,webwork都是非常好的web框架Q都有自w的优缺点:<br /> struts开创web MVC框架之先治I2003Q?004q开发的目基本都是采用struts框架Q当时招聘h的时候常问会不会strutsQ会基本招了 )Q实际MVC设计理念很早提ZQ在j2SE中有很多使用之处Q但当时没有一个web框架开发中很好的诏彻该设计理念Q直到struts 出现Q可能有Q只是没有apache更引人注意)?br /><br /> struts优点使用用户多,相关技术文档比较全面,开发遇到的问题相关案例也比较多、比较容易解冻I框架更加E_(q一炚w帔R要)?br /> <br /> webwork相对于struts来讲Q的有不少优异之处Q(也是情理之中的事Q后发布的框架如果再没有优点别h也不会用)<br /> 个h认ؓ在开发上主要有以下几点:<br /><br /> 1、页面数据封装成值对象功能比struts强大Qwebwork采用ognlcd转化?br /> struts只能对简单类型的数据对象以及文g对象装成值对? 而webwork装的值对象基本没有限Ӟ值对象属性还可以是List,Mapq些对象Q这个特性在我们开发一些批量数据、复杂数据处理时非常方便Q,减少很多代码量,代码非常整洁?br /> <br /> 2、拦截器功能<br /> 拦截器是webwork的一个亮点,实际上也是业界比较流行的AOP的一个体玎ͼ在实际开发中你可以配|默认的拦截器, 也可以ؓ单独的模块指定特定的拦截器,q且可自定义拦截器,action执行前后拦截都可以。?br /> <br /> 3、单元测试比较方?br /> 最早用struts框架开发测试时Q相关的单元试基本是不好做的,无法qweb环境Q测试都是只做集成测试、系l测试?br /> 使用webwork可以单对action相关属性赋|可以相关的单元测试,当然前提是在对应action中没有引用web环境相关的对象。?br /> 其实webwork框架核心q是xwork框架Q最早框架用在C/Sl构下,webwork只是xwork的一个在web环境的实玎ͼ只是ActionContext 上下文发生了变化Q所以说action能够做到qweb环境也是情理之中的?/p> <p> <br />4、配|文?br />webwork配置文g可以采用引用、承其他配|文件方式,在团队开发一般都是分模块开发,q样比较方便Q配|管理更ҎQ不会冲H?br /><br />5、模板技术集?br /> 我在实际应用目中是采用velocity模板做视囑ֱ玎ͼ因ؓ在对应版本的webwork框架中和velociy集成的相当好Q比较方便, 比直接写jsp代码更整z、同时利用velocity模板Ҏ结合每个action的配|文Ӟ可实现比较通用的页面查询、录入等视图的展现?br /> 而struts是没有相x杉K成,不过struts的tag相对而言比webwork的tag好用Qwebwork如果视图是jspcdQ相关的tag真的比较ȝ, 虽然tag 库很丰富Q这也是我ؓ什么用velocity做视囄原因 。?br /> <br />6?框架的效验功?br /> 老实_两者框架的效验功能都比较麻烦,相对而言webwork更加ȝ点,配置较多Q验证接口实现太ȝQ我实际目使用中还是 自定义了相兛_台验证接口, 要验证的相关action只要实现相关接口卛_Q相x截器负责拦截验证Q 大部分的效验根据配|数据以及html对象自定义属性通过javascript通用效验Q实际上现在ZXmlHttp的ajax技术应用成熟的? 后台验证接口的用途会逐渐淡化?<br /> <br /><font style="BACKGROUND-COLOR: #ffffff" color="#6666ff"> 说明上述比较版本?struts 1.0 /webwork 2.1.6Q后lstruts框架扩展很多功能Q不是很了解Q可能和上诉描述不一定很d?br /></font> <br /> 现在两者已l合qӞ希望能结合两者的优势Q发展出更好web框架?br /> <br />7、关于Hibernateq是DAO模式Q个人徏议采用hibernate+DAO盔R合的模式Qhibernate占主导地位?br /> 虽然DAO模式通过自动生成代码效率不会低,但如果需求变更就比较ȝQ维护修改代码较多,试工作量也较大Q 但Hibernate不是万能的,在一些必要的应用q是采用DAO模式Q特别是性能相关的部分?<br /> <br /> <br /> 废话一大堆Q也把我的工作回顾了一遍,呵呵Q这两天单了解Spring框架Q个人感觉Spring更像一个全面的J2EE框架解决Ҏ, 希望能够有时间系l的学习一把,大家有兴的请多多交?我会我的学习心得和大家分n?br /> <br /> </p> <p> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </p> <p> <br /> </p> <img src ="http://www.aygfsteel.com/beauty_beast/aggbug/46421.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/beauty_beast/" target="_blank">柳随?/a> 2006-05-16 15:45 <a href="http://www.aygfsteel.com/beauty_beast/archive/2006/05/16/46421.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Zlog4j实现l一日志理http://www.aygfsteel.com/beauty_beast/archive/2006/03/16/35681.html柳随?/dc:creator>柳随?/author>Thu, 16 Mar 2006 08:49:00 GMThttp://www.aygfsteel.com/beauty_beast/archive/2006/03/16/35681.htmlhttp://www.aygfsteel.com/beauty_beast/comments/35681.htmlhttp://www.aygfsteel.com/beauty_beast/archive/2006/03/16/35681.html#Feedback0http://www.aygfsteel.com/beauty_beast/comments/commentRss/35681.htmlhttp://www.aygfsteel.com/beauty_beast/services/trackbacks/35681.html背景Q?BR>       一般操作系l的告警有相关的YӞ但我们应用日志往往无法l一监控、分析。因为最q的目是比较大的一个^収ͼ有七、八个子pȝQweblogic域也有三、四个。如果用戯w能够实时监控到应用U致命异常日?如OutOfMemory,U程挂死、应用接口无法链接等{。那么我们监控维护h员工作就大大化,不然要查看所有域的日志信息,只需集中看一处,pȝ故障也能够更快的解决Q恢复正常?BR>       用户的需求是要求我们日志输出到一个第三方厂家的日志Server?/P>

设想Q?BR>        weblogic platform域的日志输出是可配置的,?bea/weblogic/common/lib/workshopLogCfg.xml, 原先的一个项目所有的日志输出均在此文件中配置。其他中间g本h很少使用Q相信也有类似的功能Qlog4j日志框架支持l一日志理功能,单实现原理(启动一个SocketServer,处理各个客户端机器连接的Socket输入Q?BR>而每个应用打印日志用Socket方式日志内容输出到SocketServer端)。如果能重要的的中间g异常日志以及应用异常日志到统一日志服务器,实时分析Q这样就方便日常监控Q有点类g讑֤告警的功能,如果再开发出相关日志分析软gQ个得会是^台产品的一个亮点,正如《少林球》说的有Ҏ头?/P>

实践Q?BR>    实践证明现实和理xd有一定的差距Q呵c下面描q验证、学习心得:
    首先描述log4j是如何实现统一日志理该功能的?BR>    核心c:
    一、org.apache.log4j.net.SocketServer 
    主要功能Q?BR>                      1、启动SocketServer
                      2、接受Socketh
                      3、初始化对应Socket的日志输出配|,如没有,采用通用配置
                      4、另启线E处理客LSocket和服务端交互
    一个比较标准的多线E处理实现?BR>     启动Server需要有三个q行参数Q端口号、log4j配置文g、客L日志在Server端输出配|文件目?BR>     q行命o如下Q?BR>                     java -classpath ../lib/log4j-1.2.8.jar;.; test.logserver.FixSocketServer   8088   server.properties  d:/temp
     说明Q?BR>              a、客L日志在Server端输出配|文件命名规?$ip.lcf ,    ?10.21.11.10.lcf  
                        该类在解析该配置文g的代码中 应该存在个bugQ版?.2.9)
                                           代码176 ?nbsp;  String key = s.substring(0,i);改ؓ:   String key = s.substring(i+1);
              b、配|文件内容和一般log4j配置内容雷同Qcategories、appenders、layouts 
     二、org.apache.log4j.net.SocketAppender
             该类l承于AppenderSkeletonQ如果我们需要自定义Appender,可以l承AppenderSkeletonc,实现ҎQ?/P>

protected  void append(LoggingEvent event);

    主要功能Q?nbsp;
                     1、连接到SocketServer,q创Z个到SocketServer的对象输出实?BR>                     2、如果连接失败,会启动一个守护线E,每隔三十U钟重新q接
                     3、日志输出时Q将日志事g对象输出到SocketServer
     相对应的日志配置Q?BR>        

log4j.appender.mysocket=test.logserver.SocketAppender 
log4j.appender.mysocket.RemoteHost
=10.243.17.85 
log4j.appender.mysocket.Port
=8088 
log4j.appender.mysocket.LocationInfo
=true 
log4j.appender.mysocket.layout
=org.apache.log4j.PatternLayout 
log4j.appender.myConsole.layout.ConversionPattern
=%5p [%t] (%F:%L) - %m%n


      三、org.apache.log4j.net.SocketNode
              该类相对单,一个线E类
     主要功能Q?BR>                     负责接收客户端对应输出对象,Ҏ对应的配|,输出相关日志?BR>
      可以看出是通过对象q行传输的,如果W三方不是采用java语言的,实际解决时只需改写SocketAppender的appendҎQ输出日志内容就可。对方实现SocketServer功能可Q编E语a基本都支持该功能Q?BR>
       遗憾的是在weblogic 一般server域中我没有找到可以改变日志输出的地方Q上ơ看到weblogic9.0中有日志服务Q不知道能不能改变)Q所以实际差距还是比较大的,关于性能问题Q因为是重要的日?warning、error、fetal)才输?采用socket方式问题应该不大?BR>
外话:               
           查看代码中无意中发现log4j框架一部分源码都是一些h捐献的。虽然代码不复杂Q但感觉己喜Ƣ的框架很热心,希望它变的越来越好,真的希望我们国内也能有一些优U的开源项目,q且大家都去支持它,发展它?BR>           实际我在目中用log4j使用的都是一些基本功能,对它的设计、结构不是很清楚Q谁有相兛_习文档,L我一份,不甚感激Q用手册已有)?BR>


   
                                           



]]>
վ֩ģ壺 | 㶫ʡ| | | | | Ϫ| | | ޭ| ֦| | կ| ¡Ң| | | ʡ| | | ԭ| | ǰ| | | | ˮ| | Ѷ | | | ƽ| Դ| | | ľ| Ӻ| ͨ| ƽ| | ˹| ʢ|