Spring Data Access and Web 笔记
2011-06-17 17:27
447 查看
Spring: Data access using JDBC There are a number of options for selecting an approach to form the basis for your JDBC datababse. There are three flavors of the JdbcTemplate, a new "SimpleJdbc" approach taking advantage of data metadata. 1.JdbcTemplate 2.NamedParameterJdbcTemplate wraps a JdbcTemplate to provide more convenient usage with named parameters instead of the traditional JDBC. 3.SimpleJdbcTemplate This class combines the most frequently used features of both JdbcTemplate and NamedParameterJdbcTemplate plus it adds additional convenience by taking advantage of some Java 5 features like varargs, autoboxing and generics to provide an easier to use API . Requires JDK 5 or higher. 4.SimpleJdbcInsert and SimpleJdbcCall This will simplify the coding to a point where you only need to provide the name of the table or procedure and provide a Map of parameters matching the column names. Designed to work together with the SimpleJdbcTemplate. 5.RDBMS Object including MappingSqlQuery, SqlUpdate and StoredProcedure 常继承SimpleJdbcDaoSupport 这个类去操作数据库。 使用iBatis时继承SqlMapClientDaoSupport Spring Web: 1.AbstractController 2.AbstractCommandController 3.SimpleFormController Application controllers will typically be subclasses of those. Note that you can choose an appropriate base class: if you don't have a form, you don't need a for controller. This is a major difference to Struts. One of the overarching design principles in Spring Web MVC(and in Spring in general ) is the "Open for extension, closed for modification" princle. Spring URL Mapping: 1.BeanNameUrlHandlerMapping <beans> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> <bean name="/editaccount.form" class="org.springframework.web.servlet.mvc.SimpleFormController"> <property name="formView" value="account"/> <property name="successView" value="account-created"/> <property name="commandName" value="account"/> <property name="commandClass" value="samples.Account"/> </bean> <beans> 2.SimpleUrlHandlerMapping <beans> <!-- no 'id' required, HandlerMapping beans are automatically detected by the DispatcherServlet --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /*/account.form=editAccountFormController /*/editaccount.form=editAccountFormController /ex/view*.html=helpController /**/help.html=helpController </value> </property> </bean> <bean id="helpController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/> <bean id="editAccountFormController" class="org.springframework.web.servlet.mvc.SimpleFormController"> <property name="formView" value="account"/> <property name="successView" value="account-created"/> <property name="commandName" value="Account"/> <property name="commandClass" value="samples.Account"/> </bean> <beans> redirect: prefix forward: prefix
相关文章推荐
- Python Web-第三周-Networks and Sockets(Using Python to Access Web Data)
- Web Intelligence and Big Data 笔记
- Cousera-Using python to access web data(第2~4周笔记)
- Web Mining and Big Data 公开课学习笔记 ---lecture0
- Python Web-第五周-Web Services and XML(Using Python to Access Web Data)
- Python Web-第六周-JSON and the REST Architecture(Using Python to Access Web Data)
- Web Mining and Big Data 公开课学习笔记 ---lecture1
- 读论文《Probabilistic Data Structures for Web Analytics and Data Mining》笔记
- Spring Data Redis -----笔记4
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- 详解spring boot Websocket使用笔记
- APUE 学习笔记 - Chapter 6. System Data File and Infomation
- iOS 7应用开发公开课笔记 L12:Documents and Core Data
- SpringData入门笔记(四) - 花式查询
- Object Relational Mapping (ORM) data access(Spring)
- Java Data Access: JDBC, JNDI, and JAXP
- How to setup multiple data sources with Spring and JPA
- The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced
- Export Grid Data To Excel In Advance Kendo UI Using MVC WEB API And Entity Framework
- How to Cheat at Configuring Exchange Server 2007: Including Outlook Web, Mobile, and Voice Access