package com.guor.mapper;
import com.guor.entity.Student;
public interface StudentMapper {
public void addStudent(Student student);
public Student queryStudentByStuNo(int id);
}
<?xml version="1.0" encoding="UTF-8" ?>select * from student where id = #{stuNo}
insert into student(id,name,age) values (#{id},#{name},#{age})
(3)service(面向接口编程)
package com.guor.service;
import com.guor.entity.Student;
public interface IStudentService {
public void addStudent(Student student);
public Student queryStudentByStuNo(int id);
}
package com.guor.service.impl;
import com.guor.entity.Student;
import com.guor.mapper.StudentMapper;
import com.guor.service.IStudentService;
public class StudentServiceImpl implements IStudentService {
private StudentMapper studentMapper;
public void setStudentMapper(StudentMapper studentMapper) {
this.studentMapper = studentMapper;
}
@Override
public void addStudent(Student student) {
studentMapper.addStudent(student);
}
@Override
public Student queryStudentByStuNo(int id) {
return studentMapper.queryStudentByStuNo(id);
}
}
(4)controller
package com.guor.controller;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.guor.entity.Student;
import com.guor.service.IStudentService;
@Controller
@RequestMapping(“studentController”)
public class StudentController {
@Autowired
@Qualifier(“studentService”)
private IStudentService studentService;
public void setStudentService(IStudentService studentService) {
this.studentService = studentService;
}
@RequestMapping(“queryStudentByStuNo/{id}”)//映射
public String queryStudentByStuNo(@PathVariable(“id”) Integer id,Map<String,Object> map) {
Student student = studentService.queryStudentByStuNo(id);
map.put(“student”, student);
return “result”;
}
}
四、Spring整合SpringMVC
1、jar包
一个就行,spring-webmvc-4.3.9.RELEASE.jar
2、配置
<?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:mvc=“http://www.springframework.org/schema/mvc” xmlns:tx=“http://www.springframework.org/schema/tx”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframew 需要zi料+ 绿色徽【vip1024b】
ork.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:component-scan base-package=“com.guor.controller”></context:component-scan>
mvc:annotation-driven</mvc:annotation-driven>
结尾
这不止是一份面试清单,更是一种”被期望的责任“,因为有无数个待面试者,希望从这篇文章中,找出通往期望公司的”钥匙“,所以上面每道选题都是结合我自身的经验于千万个面试题中经过艰辛的两周,一个题一个题筛选出来再次对好答案和格式做出来的,面试的答案也是再三斟酌,深怕误人子弟是小,影响他人仕途才是大过,也希望您能把这篇文章分享给更多的朋友,让他帮助更多的人,帮助他人,快乐自己,最后,感谢您的阅读。
由于细节内容实在太多啦,在这里我花了两周的时间把这些答案整理成一份文档了,在这里只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
0368330328)]
这不止是一份面试清单,更是一种”被期望的责任“,因为有无数个待面试者,希望从这篇文章中,找出通往期望公司的”钥匙“,所以上面每道选题都是结合我自身的经验于千万个面试题中经过艰辛的两周,一个题一个题筛选出来再次对好答案和格式做出来的,面试的答案也是再三斟酌,深怕误人子弟是小,影响他人仕途才是大过,也希望您能把这篇文章分享给更多的朋友,让他帮助更多的人,帮助他人,快乐自己,最后,感谢您的阅读。
由于细节内容实在太多啦,在这里我花了两周的时间把这些答案整理成一份文档了,在这里只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!