Spring Data Access and 網頁筆記

來源:互聯網
上載者:User
Spring: Data access using JDBCThere 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 takingadvantage of data metadata.1.JdbcTemplate2.NamedParameterJdbcTemplatewraps a JdbcTemplate to provide more convenient usage with named parameters instead of the traditional JDBC.3.SimpleJdbcTemplateThis 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 SimpleJdbcCallThis 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時繼承SqlMapClientDaoSupportSpring Web:1.AbstractController2.AbstractCommandController3.SimpleFormControllerApplication 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: prefixforward: prefix

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.