First iteration, first time

Source: Internet
Author: User

First iteration, first time

/Ball/hnzj/controller/Chaxun. javapackage controller; import org. springframework. beans. factory. annotation. autowired; import org. springframework. stereotype. controller; import org. springframework. web. bind. annotation. requestMapping; import org. springframework. web. servlet. modelAndView; import domain. user; import service. chaxunService; @ Controller @ RequestMapping ("/chaxun") public class Chaxun {@ Autowired privat E ChaxunService chaxunService; @ RequestMapping ("/chaxun") private String chaxun (User user) {return "chaxun" ;}@ RequestMapping ("/jieguo ") public ModelAndView jieguo (User user) {User user2 = chaxunService. getVs (user); ModelAndView mv = new ModelAndView (); mv. setViewName ("jieguo"); mv. addObject ("aa", user2); return mv ;}/ ball/hnzj/dao/ChaxunDao. javapackage dao; import domain. user; public interface Chax UnDao {public User getVs (User user); public User getDefen (User user);}/ball/hnzj/domain/User. javapackage domain; public class User {private int id; private String vs; private String defen; private String huoshengfang; public String getDefen () {return defen;} public void setDefen (String defen) {this. defen = defen;} public String getHuoshengfang () {return huoshengfang;} public void setHuoshen Gfang (String huoshengfang) {this. huoshengfang = huoshengfang;} public int getId () {return id;} public void setId (int id) {this. id = id;} public String getVs () {return vs;} public void setVs (String vs) {this. vs = vs ;}@ Override public String toString () {return "User [id =" + id + ", vs =" + vs + ", defen = "+ defen +", huoshengfang = "+ huoshengfang +"] ";}}/ball/hnzj/service/ChaxunServic E. javapackage service; import domain. user; public interface ChaxunService {public User getVs (User user); public User getDefen (User user User);}/ball/hnzj/service/Impl/ChaxunServiceImpl. javapackage service. impl; import org. springframework. beans. factory. annotation. autowired; import org. springframework. stereotype. service; import dao. chaxunDao; import domain. user; import service. chaxunService; @ Servicepublic clas S ChaxunServiceImpl implements ChaxunService {@ Autowired private ChaxunDao chaxunDao; @ Override public User getVs (User user) {return chaxunDao. getVs (user) ;}@ Override public User getDefen (User user) {return chaxunDao. getDefen (user) ;}}/ball/config/mybatis/mapper/ChaxunDao. xml <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE mapper PUBLIC "http://mybatis.org/dtd/mybatis-3-mapper.dtd" "mybatis-3-mapper.dtd"> <mapper namespace = "dao. chaxunDao "> <select id =" getVs "parameterType =" User "resultType =" User "> select * from ball where vs =#{ }; </select> <select id = "getDefen" parameterType = "User" resultType = "User"> select * from ball where defen =#{ defen }; </select> </mapper>/ball/config/mybatis/config. xml <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE configuration PUBLIC "http://mybatis.org/dtd/mybatis-3-config.dtd" "mybatis-3-config.dtd"> <configuration> <typeAliases> <typeAlias type = "domain. user "alias =" User "/> </typeAliases> </configuration>/ball/config/spring/applicationContext. xml <? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: aop = "http://www.springframework.org/schema/aop" xmlns: context = "http://www.springframework.org/schema/context" xmlns: p = "http://www.springframework.org/schema/p" xmlns: tx = "http://www.springframework.org/schema/tx" xsi: schemaLocation = "http://www.springframework.org/schema/beans http :/ /Www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd "> <context: annotation-c Onfig/> <context: component-scan base-package = "service"/> <! -- Load the database configuration file jdbc. properties --> <context: property-placeholder location = "classpath: jdbc. properties"/> <! -- Configure the database connection pool and use dbcp connection pool --> <bean id = "dataSource" class = "org. apache. commons. dbcp. basicDataSource "p: url =" $ {jdbc. url} "p: username =" $ {jdbc. username} "p: password =" $ {jdbc. password} "p: driverClassName =" $ {jdbc. driver} "p: maxActive =" 30 "p: maxIdle =" 10 "p: maxWait =" 1000 "p: initialSize =" 15 "/> <! -- Configure the myBatis session factory class, specify the data source, Master configuration file, mapper ing file, and object class package information --> <bean id = "sqlSessionFactory" class = "org. mybatis. spring. sqlSessionFactoryBean "p: dataSource-ref =" dataSource "p: configLocation =" classpath: mybatis/config. xml "p: mapperLocations =" classpath: mybatis/mapper /**/*. xml "/> <! -- Specifies the location of the dao interface. This class automatically creates an interface implementation class Based on the interface and mapper configuration file information. The service layer can directly use it --> <bean class = "org. mybatis. spring. mapper. mapperScannerConfigurer "p: basePackage =" dao "/> <! -- Configure the Transaction Manager --> <bean id = "txManager" class = "org. springframework. jdbc. datasource. dataSourceTransactionManager "p: dataSource-ref =" dataSource "/> <aop: config> <aop: pointcut expression =" execution (* hnzj. *. service. **. *(..)) "id =" serviceMethods "/> <aop: advisor advice-ref =" txAdvice "pointcut-ref =" serviceMethods "/> </aop: config> <! -- Wrap the transaction manager into advice --> <tx: advice id = "txAdvice" transaction-manager = "txManager"> <tx: attributes> <tx: method name = "save" propagation = "REQUIRED"/> </tx: attributes> </tx: advice> </beans>/ball/config/spring/spring-mvc.xml <? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: context = "http://www.springframework.org/schema/context" xmlns: p = "http://www.springframework.org/schema/p" xmlns: mvc = "http://www.springframework.org/schema/mvc" xsi: schemaLocation = "http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd "> <mvc: annotation-driven/> <! -- Scan control layer --> <context: component-scan base-package = "controller"/> <! -- The returned logical view matches the actual view --> <bean class = "org. springframework. web. servlet. view. internalResourceViewResolver "p: prefix ="/WEB-INF/jsp/"p: suffix = ". jsp "/> </beans>/ball/config/jdbc. propertiesjdbc. username = rootjdbc. password = rootjdbc. url = jdbc: mysql: // localhost: 3306/login? UseUnicode = true & amp; characterEncoding = utf8jdbc. driver = com. mysql. jdbc. driver/ball/WebContent/WEB-INF/jsp/chaxun. jsp <% @ page language = "java" contentType = "text/html; charset = UTF-8" pageEncoding = "UTF-8" %> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> 

 

Recently I want to open a project "Examination System"

Ssm framework

Spring MVA Spring MyBatis

As soon as I learned how to build the framework, the teacher asked for the first iteration. After learning to use the framework, I used ssm for this iteration.

During the iteration process, many people did not understand it, thanks to the smooth operation of our leader Peng Fei and qingniao banwang. Teacher Chen, I can't think about it. I didn't understand the requirement book yesterday !!!

There are a lot of code. I only understood each layer yesterday. Sorry, I forgot to add comments. You can't understand them. (Good coding habits should be developed)

Although it is a very small function, it is very small and dirty.

There are some jar packages in it. If you want to run it, please contact me to give you the jar package.

Access page address: http: // localhost: 8080/ball/chaxun

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.