8000 GitHub - BosukNam/spring-mvc: getting started spring mvc with DD(Deployment Descriptor) ver2.5
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

BosukNam/spring-mvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-mvc

getting started spring mvc with DD(Deployment Descriptor) ver2.5

  1. create a new project with Dynamic Web Project (DD ver2.5).
  2. convert project to maven. (right click on Project -> Configure)
  3. add Spring Project Nature. (right click on Project -> Spring Tools)
  4. add dependencies in pom.xml
  5. create spring configuration files.
  6. update your DD file with condition #5.
  7. create java, jsp files.
  8. run with tomcat

nextstep: getting started mybatis

getting started with mybatis on this project

  1. add mybatis, mybatis-spring, spring-jdbc, mysql dependencies on pom.xml
<dependency>
	<groupId>org.mybatis </groupId>
	<artifactId>mybatis </artifactId>
	<version>3.4.2 </version>
</dependency>
<dependency>
	<groupId>org.mybatis </groupId>
	<artifactId>mybatis-spring </artifactId>
	<version>1.3.0 </version>
</dependency>
<dependency>
	<groupId>org.springframework </groupId>
	<artifactId>spring-jdbc </artifactId>
	<version>4.1.0.RELEASE </version>
</dependency>
<dependency>
	<groupId>mysql</groupId>
	<artifactId>mysql-connector-java</artifactId>
	<version>5.1.44</version>
</dependency>
  1. add xmlns: context and xsi:schemaLocation about spring-beans, spring-context on spring-controller.xml file
  2. add <context:annotation-config/> and beans (datasource, sqlSesscionFactory, sqlSession, user DAO etc…)
  3. create mapper files which location that you wrote on mapperLocations value
<property name="mapperLocations" value="classpath:/sql/*.xml"/>
  1. execute your sql with SqlSession. (there are many methods in Sqlsession class)
@Autowired
private SqlSession session;
@RequestMapping("/hello") public String hello(Model model, @RequestParam(value="name",required=false)String name){ model.addAttribute("greeting","안녕하세요, "+name);
List<Map<String, Object>> resultMap = session.selectList("AccountMapper.selectAll"); for(Map<String, Object> map : resultMap){ System.out.println(map); } return "hello"; }

About

getting started spring mvc with DD(Deployment Descriptor) ver2.5

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0