当前位置: 首页 > news >正文

北京网站开发招聘网站建设教程开源代码下载

北京网站开发招聘,网站建设教程开源代码下载,wordpress怎么修改文字,杭州高端网站建设公司这里写目录标题 一、项目结构1、model模型类Student2、mapper 数据访问层接口和映射文件接口类StudentMapper接下来创建名为 StudentMapper.xml 的映射文件 3、service 服务层接口和实现类创建名为 StudentService 的 Java 接口创建名为 StudentServiceImpl 的实现类 4、contro… 这里写目录标题 一、项目结构1、model模型类Student2、mapper 数据访问层接口和映射文件接口类StudentMapper接下来创建名为 StudentMapper.xml 的映射文件 3、service 服务层接口和实现类创建名为 StudentService 的 Java 接口创建名为 StudentServiceImpl 的实现类 4、controller5、配置 resources5-1、mapper5-2、mysqldb.properties5-3、spring.xml5-4、springmvc.xml controller 存放控制器Controller类处理请求和返回响应。 mapper 存放数据访问层Mapper接口和对应的XML文件。 model 存放模型Model类与数据库表对应。 service 存放服务Service接口和实现类 impl resources mapper文件 存放Mapper接口对应的XML文件定义SQL语句和映射关系。 mybatis-config.xmlMyBatis的主配置文件配置数据库连接等全局设置。 db.properties数据库连接信息的配置文件。 project-name ├── src │ ├── main │ │ ├── java # Java代码目录 │ │ │ ├── com.example.project.controller # 控制器包 │ │ │ ├── com.example.project.mapper # Mapper接口和XML文件包 │ │ │ ├── com.example.project.model # 模型包 │ │ │ ├── com.example.project.service # 业务逻辑包 │ │ │ └── com.example.project.util # 工具类包 │ │ ├── resources # 资源目录 │ │ │ ├── mapper # 存放Mapper对应的XML文件 │ │ │ ├── mybatis-config.xml # MyBatis主配置文件 │ │ │ └── db.properties # 数据库连接配置文件 │ │ └── webapp # Web资源目录 │ │ ├── WEB-INF # Web应用配置目录 │ │ │ ├── web.xml # Web应用配置文件 │ │ │ └── spring.xml # Spring配置文件如果使用Spring │ │ ├── index.jsp # 首页JSP文件 │ │ └── static # 静态资源目录 │ │ ├── css # CSS文件目录 │ │ ├── js # JavaScript文件目录 │ │ └── images # 图片目录 └── pom.xml # Maven项目配置文件 一、项目结构 1、model模型类Student public class Student {private Long id;private String name;private Integer age;private String gender;// getter 和 setter 方法省略 } 2、mapper 数据访问层接口和映射文件 接口类StudentMapper // 2. 定义数据访问层接口和映射文件package com.example.mapper;public interface StudentMapper {void insert(Student student); // 插入学生信息void delete(Long id); // 删除学生信息void update(Student student); // 更新学生信息Student selectById(Long id); // 根据ID查询学生信息ListStudent selectAll(); // 查询所有学生信息 } 接下来创建名为 StudentMapper.xml 的映射文件 ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd !-- StudentMapper.xml -- !-- 映射SQL语句和Java对象之间的关系 -- mapper namespacecom.example.mapper.StudentMapper!-- 定义结果映射 --resultMap idStudentResultMap typecom.example.model.Studentid columnid propertyid/result columnname propertyname/result columnage propertyage/result columngender propertygender//resultMap!-- 插入学生信息 --insert idinsert parameterTypecom.example.model.StudentINSERT INTO student(name, age, gender) VALUES(#{name}, #{age}, #{gender})/insert!-- 删除学生信息 --delete iddelete parameterTypejava.lang.LongDELETE FROM student WHERE id#{id}/delete!-- 更新学生信息 --update idupdate parameterTypecom.example.model.StudentUPDATE student SET name#{name}, age#{age}, gender#{gender} WHERE id#{id}/update!-- 根据ID查询学生信息 --select idselectById resultMapStudentResultMapSELECT * FROM student WHERE id#{id}/select!-- 查询所有学生信息 --select idselectAll resultMapStudentResultMapSELECT * FROM student/select/mapper 3、service 服务层接口和实现类 创建名为 StudentService 的 Java 接口 // 3. 定义服务层接口和实现类package com.example.service;public interface StudentService {void add(Student student); // 添加学生信息void remove(Long id); // 删除学生信息void modify(Student student); // 修改学生信息Student findById(Long id); // 根据ID查询学生信息ListStudent findAll(); // 查询所有学生信息 } 创建名为 StudentServiceImpl 的实现类 Service public class StudentServiceImpl implements StudentService {Autowiredprivate StudentMapper studentMapper;Overridepublic void add(Student student) {studentMapper.insert(student);}Overridepublic void remove(Long id) {studentMapper.delete(id);}Overridepublic void modify(Student student) {studentMapper.update(student);}Overridepublic Student findById(Long id) {return studentMapper.selectById(id);}Overridepublic ListStudent findAll() {return studentMapper.selectAll();} } 4、controller 创建名为 StudentController 的 Java 类 // 4. 编写控制器类Controller public class StudentController {Autowiredprivate StudentService studentService;// 处理显示学生列表的请求GetMapping(/students)public ModelAndView showStudents() {ListStudent students studentService.findAll();ModelAndView mav new ModelAndView(students); // 返回视图名为studentsmav.addObject(students, students); // 将学生列表添加到模型中return mav;}// 处理显示添加学生页面的请求GetMapping(/students/new)public ModelAndView showAddStudentForm() {ModelAndView mav new ModelAndView(add_student_form); // 返回视图名为add_student_formmav.addObject(student, new Student()); // 创建一个空的学生对象并添加到模型中return mav;}// 处理提交添加学生的请求PostMapping(/students)public String addStudent(ModelAttribute(student) Student student) {studentService.add(student);return redirect:/students; // 重定向到学生列表页面}// 处理显示修改学生页面的请求GetMapping(/students/{id}/edit)public ModelAndView showEditStudentForm(PathVariable Long id) {Student student studentService.findById(id);ModelAndView mav new ModelAndView(edit_student_form); // 返回视图名为edit_student_formmav.addObject(student, student); // 将要修改的学生对象添加到模型中return mav;}// 处理提交修改学生的请求PutMapping(/students/{id})public String updateStudent(PathVariable Long id, ModelAttribute(student) Student student) {student.setId(id);studentService.modify(student);return redirect:/students; // 重定向到学生列表页面}// 处理删除学生的请求DeleteMapping(/students/{id})public String deleteStudent(PathVariable Long id) {studentService.remove(id);return redirect:/students; // 重定向到学生列表页面} } 5、配置 resources 在resources进行配置 5-1、mapper 在resources新建一个mapper文件 存放Mapper接口对应的XML文件定义SQL语句和映射关系。 5-2、mysqldb.properties 数据库连接信息的配置文件。 drivercom.mysql.jdbc.Driver urljdbc:mysql://localhost:3306/student?useSSLfalse userroot pwd1234567895-3、spring.xml 配置 Spring 容器和 MyBatis 相关内容如数据源、事务管理等 !-- 配置数据源 -- bean iddataSource classcom.zaxxer.hikari.HikariDataSourceproperty namedriverClassName value${spring.datasource.driver-class-name}/property namejdbcUrl value${spring.datasource.url}/property nameusername value${spring.datasource.username}/property namepassword value${spring.datasource.password}/property nameminimumIdle value${spring.datasource.hikari.minimumIdle}/property namemaximumPoolSize value${spring.datasource.hikari.maximumPoolSize}/ /bean!-- 配置 SqlSessionFactory -- bean idsqlSessionFactory classorg.mybatis.spring.SqlSessionFactoryBeanproperty namedataSource refdataSource/property namemapperLocations valueclasspath:mapper/*.xml/ /bean!-- 配置 MapperScannerConfigurer -- bean classorg.mybatis.spring.mapper.MapperScannerConfigurerproperty namebasePackage valuecom.example.mapper/ /bean!-- 配置事务管理器 -- bean idtransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource/ /bean!-- 开启基于注解的事务 -- tx:annotation-driven transaction-managertransactionManager/ 5-4、springmvc.xml 配置 SpringMVC 相关内容例如视图解析器、处理器映射等 mvc:annotation-driven/bean idviewResolverclassorg.springframework.web.servlet.view.InternalResourceViewResolverproperty nameprefix value/WEB-INF/jsp//property namesuffix value.jsp/ /beanmvc:resources mapping/static/** location/static//mvc:interceptorsmvc:interceptormvc:mapping path/**/bean classcom.example.interceptor.TimeInterceptor/bean/mvc:interceptor /mvc:interceptors
http://www.dnsts.com.cn/news/67098.html

相关文章:

  • 网站站长如何赚钱wordpress搬家后图片无法显示
  • 外汇做单在什么网站网站备案名称的影响吗
  • 网站建设工作情况总结企业网站的制作方式
  • 做网站用什么插件湘潭商城网站建设定制
  • 手机网站尺寸大小中国设计在线网站
  • 南宁物流公司网站建设哈尔滨悦创网络科技网站开发
  • 青岛建网站人企业做app好还是网站好
  • 怎么做网站加载动画网站平台有哪些
  • mvc 手机网站开发免费ppt资源网站
  • 如何让网站被百度快速收录攻击Wordpress网站
  • 找个网站怎么这么难wordpress滑动门
  • 有哪些做包装设计网站好些网上书店网站建设实训报告总结
  • 中国科协网站建设招标网站建设的现状和未来
  • 阿里云免费建站wordpress快
  • 禁止拿我们的网站做宣传网站建设需求有什么用
  • 如何在外管局网站做延期收汇免费建网站的作用
  • 免费网站设计平台惠州做棋牌网站建设
  • 做网站的前期准备免费做图片的网站有哪些
  • 厦门 网站建设 闽icpwordpress熊掌号关注
  • 网站权重排行免费推广渠道有哪些方式
  • 知名网站开发哪家好搬家公司网站制作
  • 长春网站建设团队商标自助查询系统官网
  • 网页游戏交易网站wordpress 4.5.9
  • 公司网站的推广长沙网站优化外包公司
  • 做视频在哪个网站找素材河南热点新闻事件
  • 超级简历网站网站制作公司智能 乐云践新
  • 那种投票网站里面怎么做网站建设 软件有哪些内容
  • 深圳个性化网站建设公司编写一个android应用程序
  • 泰来县城乡建设局网站湖州网站建设公司
  • 网站平台建设意见医生可以自己做网站吗