发布一个自己写的Spring2.5中文教程,希望对需要的朋友有帮助。?本文原文地址:http://www.blogjava.net/cmzy
发布一个自己写的Spring2.5中文教程,希望对需要的朋友有帮助。
?
本文原文地址:http://www.blogjava.net/cmzy/archive/2008/08/03/219688.html?
暑假无聊的很,也找不到什么中意的兼职,米事就写写东西。本来准备写成一本书的,但是到现在也没一个详细的计划,甚至书名也没定,就是Spring的东西吧。再说也要毕业了,不知道能坚持到多久,尽力把它写完。不求有多么高级,只是希望可以总结一下自己以前学的东西,写出来,希望对需要的朋友有点帮助、同时也可以得到大侠们的帮助,使我进步:-)。
开发环境是MyEclipse6.5+Spring2.5,里面介绍了一些Spring2.5的新特性,现在刚刚把IoC写完,正准备写AOP的……现在把它放出来,内容只是涉及到SpringIOC的部分,博大伙儿一笑。
下载:Spring2.5中文简明教程
声明一下,本人的“正规”专业不是计算机,水平非常有限,所以书中难免有错误和疏漏之处,欢迎大家指正,我感激不尽,email是dashoumail@163.com 。
?
?
? ? ? 另外,我博客上的大部分文章也是截取这本书上面的…………
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
value="root"></property>
<property name="password" value="219005"></property>
</bean>
<bean id="sessionFactory"
+ id);
try {
User instance = (User) getHibernateTemplate().get("vo.User", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(User instance) {
log.debug("finding User instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding User instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from User as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByName(Object name) {
return findByProperty(NAME, name);
}
public List findByPassword(Object password) {
return findByProperty(PASSWORD, password);
}
public List findAll() {
log.debug("finding all User instances");
try {
String queryString = "from User";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public User merge(User detachedInstance) {
log.debug("merging User instance");
try {
User result = (User) getHibernateTemplate().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(User instance) {
log.debug("attaching dirty User instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(User instance) {
log.debug("attaching clean User instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static UserDAO getFromApplicationContext(ApplicationContext ctx) {
return (UserDAO) ctx.getBean("UserDAO");
}
}
*********************************************************************
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
**********************************<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>JavaEye Java编程 Spring框架 AJAX技术 Agile敏捷软件开发 ruby on rails实践-JavaEye做最棒的软件开发交流社区</title>
<meta name="description" content="Java编程,Spring Struts Webwork框架深入,XMLHTTP AJAX开发,Java Web开发,Java企业应用,Java设计模式,Java开源框架,Java应用服务器,Rich Client讨论,Ruby编程,Ruby DSL开发,Ruby on rails实践,JavaScript编程,敏捷软件开发XP TDD,软件配置管理,软件测试,项目管理UML,数据库,C#/.net C/C++ Erlang/FP PHP/Linux平台,精通Hibernate" />
<meta name="keywords" content="Java编程 Spring框架 AJAX技术 Agile敏捷软件开发 ruby on rails实践 软件工程 讨论 论坛 JavaEye深度技术社区" />
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
<link href="/rss/board/Java" rel="alternate" title="JavaEye论坛" type="application/rss+xml" />
<link href="http://www.iteye.com/stylesheets/forum.css?1219503638" media="screen" rel="stylesheet" type="text/css" />
<script src="http://www.iteye.com/javascripts/application.js?1214967926" type="text/javascript"></script>
<link href="http://www.iteye.com/javascripts/syntaxhighlighter/SyntaxHighlighter.css?1201588027" media="screen" rel="stylesheet" type="text/css" />
<script src="http://www.iteye.com/javascripts/syntaxhighlighter/shCoreCommon.js?1203397332" type="text/javascript"></script>
<link href="http://www.iteye.com/javascripts/syntaxhighlighter/SyntaxHighlighter.css?1201588027" media="screen" rel="stylesheet" type="text/css" />
<script src="http://www.iteye.com/javascripts/tinymce/tiny_mce.js?1207707663" type="text/javascript"></script>
<script src="http://www.iteye.com/javascripts/syntaxhighlighter/shCoreCommon.js?1203397332" type="text/javascript"></script>
<link href="http://www.iteye.com/javascripts/editor/css/ui.css?1212551310" media="screen" rel="stylesheet" type="text/css" />
<script src="http://www.iteye.com/javascripts/editor/compress.js?1217921045" type="text/javascript"></script>
</head>
<body>
<div id="page">
<div id="header" src="http://www.iteye.com/images/logo.gif?1212054226" title="JavaEye-最棒的软件开发交流社区" /></a>
</div>
<div id="ad">
<embed width="720" height="60" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://ftp.iteye.com/public/ibm/bbs2.swf" play="true" loop="true" menu="true"></embed>
</div>
</div>
<div id="content" enctype="multipart/form-data" id="editor_form" method="post"> <table id="forum_main" cellspacing="1">
<thead>
<tr>
<td colspan="2">发表回复</td>
</tr>
</thead>
<tbody>
<tr>
<td id="editor_tab_bbcode" onclick="editor.switchMode('bbcode', true); return false;">BBCode编辑器</a></li>
<li><a href="#" id="editor_tab_rich" onclick="editor.switchMode('rich', true); return false;">可视化编辑器</a></li>
<li><a href="#" id="editor_tab_preview" onclick="editor.preview();; return false;">预览</a></li>
</ul>
<span id="editor_switch_spinner" style="padding-left: 5px; display: none;"><img alt="公布一个自己写的Spring2.5中文教程,希望对需要的朋友有帮助" src="http://www.iteye.com/images/spinner.gif?1182413454" /></span>
<span id="editor_auto_save_update" style="padding-left: 5px;"></span>
</div>
<input type="hidden" name="auto_save_id" id="editor_auto_save_id"/>
<div id="editor_preview" style="display:none;background-color:white;border:1px solid gray;padding:20px 5px;width:95%;overflow-x:auto;"></div>
<input id="editor_bbcode_flag" name="post[bbcode]" type="hidden" value="true" />
<div id="editor_main"><textarea cols="40" id="editor_body" name="post[body]" rows="20" style="width: 650px; height: 350px;"></textarea></div>
<script type="text/javascript">
var editor = new Control.TextArea.Editor("editor_body", "bbcode", true);
</script>
</td>
</tr>
<tr>
<td id="attachment_upload"/>
<script type="text/javascript">
var multiple_upload_attachment_counter = 0;
multiple_upload_attachment($("attachment_upload"), 3);
</script></td>
</tr>
<tr>
<td colspan="2" align="center" id="submit_button" name="commit" type="submit" value="提交" /></td>
</tr>
</tbody>
</table>
</form>
<div style="text-align:center; padding:20px 0 0 10px; text-align:center; font-weight:bold;">主题回顾</div>
<div style="height: 300px; overflow: auto">
<table id="forum_main" cellspacing="1">
<thead>
<tr>
<td>作者</td>
<td>正文</td>
</tr>
</thead>
<tbody>
<tr>
<td class='selected'>论坛</a></li>
<li><a href="http://www.iteye.com/ask">问答</a></li>
<li><a href="http://www.iteye.com/wiki">知识库</a></li>
<li><a href="http://www.iteye.com/blogs">博客</a></li>
<li><a href="http://www.iteye.com/groups">圈子</a></li>
<li><a href="http://www.iteye.com/jobs">招聘</a></li>
<li><a href="http://www.iteye.com/index/service">服务</a></li>
<li >Java</a></li>
<li><a href="http://ruby.iteye.com" >Ruby</a></li>
<li><a href="http://ajax.iteye.com" >AJAX</a></li>
<li><a href="http://agile.iteye.com" >敏捷</a></li>
<li><a href="http://book.iteye.com" >图书</a></li>
<li><a href="http://oracle.iteye.com" >Oracle</a></li>
<li >普元</a></li>
</ul>
</div>
</div>
<div id="footer">
<div id="site_nav">
<ul>
<li><a href="/index/service">广告服务</a></li>
<li><a href="http://webmaster.iteye.com">JavaEye黑板报</a></li>
<li><a href="/index/sitemap">网站地图</a></li>
<li><a href="/index/aboutus">关于我们</a></li>
<li><a href="/index/contactus">联系我们</a></li>
<li class="last"><a href="/index/friend_links">友情链接</a></li>
</ul>
</div>
<div id="copyright">
© 2003-2008 iteye.com. All rights reserved. 上海炯耐计算机软件有限公司 [ 沪ICP备05023328号 ]
</div>
</div>
</div>
</body>
</html>