Spring+SpringMVC+MyBatis整合,java常用框架面试

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>

结尾

查漏补缺:Java岗 千+道面试题Java基础+全家桶+容器+反射+异常等

这不止是一份面试清单,更是一种”被期望的责任“,因为有无数个待面试者,希望从这篇文章中,找出通往期望公司的”钥匙“,所以上面每道选题都是结合我自身的经验于千万个面试题中经过艰辛的两周,一个题一个题筛选出来再次对好答案和格式做出来的,面试的答案也是再三斟酌,深怕误人子弟是小,影响他人仕途才是大过,也希望您能把这篇文章分享给更多的朋友,让他帮助更多的人,帮助他人,快乐自己,最后,感谢您的阅读。

由于细节内容实在太多啦,在这里我花了两周的时间把这些答案整理成一份文档了,在这里只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
0368330328)]

这不止是一份面试清单,更是一种”被期望的责任“,因为有无数个待面试者,希望从这篇文章中,找出通往期望公司的”钥匙“,所以上面每道选题都是结合我自身的经验于千万个面试题中经过艰辛的两周,一个题一个题筛选出来再次对好答案和格式做出来的,面试的答案也是再三斟酌,深怕误人子弟是小,影响他人仕途才是大过,也希望您能把这篇文章分享给更多的朋友,让他帮助更多的人,帮助他人,快乐自己,最后,感谢您的阅读。

由于细节内容实在太多啦,在这里我花了两周的时间把这些答案整理成一份文档了,在这里只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!

  • 22
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值