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

建设完网站如何信息更新湘潭seo培训

建设完网站如何信息更新,湘潭seo培训,陕西网页设计培训,怎么进入广告联盟看广告赚钱SpringBoot2(Spring Boot 的Web开发 springMVC 请求处理 参数绑定 常用注解 数据传递 文件上传) 一、Spring Boot的Web开发 1.静态资源映射规则 总结:只要静态资源放在类路径下: called /static (or /public or /resources or …

SpringBoot2(Spring Boot 的Web开发 springMVC 请求处理 参数绑定 常用注解 数据传递 文件上传)

一、Spring Boot的Web开发

1.静态资源映射规则

在这里插入图片描述

总结:只要静态资源放在类路径下:

called /static (or /public or /resources or //METAINF/resources

一启动服务器就能访问到静态资源文件

springboot只需要将图片放在 static 下 就可以被访问到了

** 总结: **

只要静态资源放在类路径下: called /static (or INF/resources

访问 : 当前项目根路径/ + 静态资源名

**静态资源访问前缀 **

spring:mvc:static-path-pattern: static/test/**


2.enjoy模板引擎

“四个步骤”

1.添加坐标

<dependency><groupId>com.jfinal</groupId><artifactId>enjoy</artifactId><version>5.0.3</version>
</dependency>

2.开启配置

package com.stringzhua.springboot_web_demo01.config;import com.jfinal.template.Engine;
import com.jfinal.template.ext.spring.JFinalViewResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class SpringBootConfig {@Bean(name = "jfinalViewResolver")public JFinalViewResolver getJFinalViewResolver() {// 创建用于整合 spring boot 的 ViewResolver 扩展对象JFinalViewResolver jfr = new JFinalViewResolver();// 对 spring boot 进行配置jfr.setSuffix(".html");jfr.setContentType("text/html;charset=UTF-8");jfr.setOrder(0);// 设置在模板中可通过 #(session.value) 访问 session 中的数据jfr.setSessionInView(true);// 获取 engine 对象,对 enjoy 模板引擎进行配置,配置方式与前面章节完全一样Engine engine  = JFinalViewResolver.engine;// 热加载配置能对后续配置产生影响,需要放在最前面engine.setDevMode(true);// 使用 ClassPathSourceFactory 从 class path 与 jar 包中加载模板文件engine.setToClassPathSourceFactory();// 在使用 ClassPathSourceFactory 时要使用 setBaseTemplatePath// 代替 jfr.setPrefix("/view/")engine.setBaseTemplatePath("/templates/");// 更多配置与前面章节完全一样// engine.addDirective(...)// engine.addSharedMethod(...);return jfr;}
}

3.将页面保存在templates目录下

4.编写代码

Spring整合mybatis-plus

“四步”

1.导入坐标

 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.3</version></dependency><!--        <dependency>-->
<!--            <groupId>org.mybatis.spring.boot</groupId>-->
<!--            <artifactId>mybatis-spring-boot-starter</artifactId>-->
<!--            <version>2.2.2</version>-->
<!--        </dependency>-->

2.编写配置实体类与关系表映射关系

package com.stringzhua.springboot_mybatis_demo01.pojo;import com.baomidou.mybatisplus.annotation.*;
import org.springframework.web.multipart.MultipartFile;import java.io.Serializable;/*** @Author Stringzhua* @Date 2024/9/19 17:21* description:*/
@TableName(value = "student")
public class Student implements Serializable {@TableId(value = "stu_id", type = IdType.AUTO)private int stuId;@TableField(value = "stu_name")private String stuName;@TableField(value = "nick_name")private String nickName;@TableField(value = "stu_age")private int stuAge;//逻辑查询@TableLogic(value = "0", delval = "1")private int isDelete;//数据库无关字段@TableField(exist = false)private MultipartFile file;@Overridepublic String toString() {return "Student{" +"stuId=" + stuId +", stuName='" + stuName + '\'' +", nickName='" + nickName + '\'' +", stuAge=" + stuAge +'}';}public int getStuId() {return stuId;}public void setStuId(int stuId) {this.stuId = stuId;}public String getStuName() {return stuName;}public void setStuName(String stuName) {this.stuName = stuName;}public String getNickName() {return nickName;}public void setNickName(String nickName) {this.nickName = nickName;}public int getStuAge() {return stuAge;}public void setStuAge(int stuAge) {this.stuAge = stuAge;}public Student() {}public Student(String stuName, String nickName, int stuAge) {this.stuName = stuName;this.nickName = nickName;this.stuAge = stuAge;}
}

3.1使用公共的数据访问层

@Mapper
public interface StudentMapper extends BaseMapper<Student> {@Select("select * from student")public List<Student> selectAll();
}

3.2使用公共业务层

4.编写配置文件

spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/mavendb?serverTimezone=Asia/Shanghaiusername: rootpassword: 12345678
mybatis:configuration:map-underscore-to-camel-case: true
mybatis-plus:configuration:map-underscore-to-camel-case: truelog-impl: org.apache.ibatis.logging.stdout.StdOutImpl #日志

mybatis-plus的增删改查:

@SpringBootTest
public class Test01 {@Autowired(required = false)StudentMapper studentMapper;//新增@Testpublic void add() {Student student = new Student("一猫人", "大熊猫本猫", 3);int count = studentMapper.insert(student);System.out.println("主键回填" + student.getStuId());System.out.println("影响的行数" + count);}//根据学生id修改@Testpublic void modifyById() {Student student = new Student();student.setStuId(12);student.setStuName("李前");student.setStuAge(18);int count = studentMapper.updateById(student);System.out.println("影响行数" + count);}//根据姓名修改,条件@Testpublic void modifyByName() {//1.修改数据Student student = new Student();student.setNickName("猫眼电影");student.setStuAge(18);//2.创建条件QueryWrapper<Student> wrapper = new QueryWrapper<>();wrapper.eq("stu_name", "猫猫");//3.执行sqlstudentMapper.update(student, wrapper);}//根据学生id查询@Testpublic void selectById() {Student student = studentMapper.selectById(10);System.out.println(student);}//根据多个学生id查询@Testpublic void selectByMoreId() {List<Student> students = studentMapper.selectBatchIds(Arrays.asList(1, 2, 3, 4, 5, 6));for (int i = 0; i < students.size(); i++) {Student student = students.get(i);System.out.println(student);}}//查询count@Testpublic void selectCount() {QueryWrapper<Student> wrapper = new QueryWrapper<>();wrapper.eq("stu_name", "猫猫");
//        int count = studentMapper.selectCount(null);//全查int count = studentMapper.selectCount(wrapper);//条件查询System.out.println(count);}//条件查询@Testpublic void selectByCondition() {QueryWrapper<Student> wrapper = new QueryWrapper<>();
//        wrapper.eq("stu_name","猫猫");//相当于这里有个and
//        wrapper.eq("nick_name","猫眼电影");//or查询wrapper.eq("stu_name", "猫猫").or().eq("nick_name", "猫眼电影");List<Student> list = studentMapper.selectList(wrapper);for (int i = 0; i < list.size(); i++) {Student student = list.get(i);System.out.println(student);}}
}

mybatis-plus的分页插件[自带]

package com.stringzhua.springboot_mybatis_demo01.config;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** @Author Stringzhua* @Date 2024/9/20 12:10* description:*/
@Configuration
public class MyBatisConfig {//注入mp拦截器@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor(){//1.实例化拦截器MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();//2.分页拦截器mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());return mybatisPlusInterceptor;}
}
@SpringBootTest
public class Test01 {@Autowired(required = false)StudentMapper studentMapper;/*** mp分页使用* 注意:* 1.page.setCurrent(2);当前页码从1开始* 2.mybatis分页需要配置插件,mp不用*///这里为逻辑分页@Testpublic void Page() {//1.定义分页规则Page<Student> page = new Page<>();page.setSize(4);//每页记录数page.setCurrent(2);//当前页码//2.条件查询(可选)QueryWrapper queryWrapper = new QueryWrapper();queryWrapper.eq("stu_sex", "男");Page<Student> iPage = studentMapper.selectPage(page, null);List<Student> list = iPage.getRecords();System.out.println("总记录数" + iPage.getTotal());System.out.println("总记页数" + iPage.getPages());for (int i = 0; i < list.size(); i++) {Student student = list.get(i);System.out.println(student);}}//逻辑删除//数据库中只是把is_delete设置为1,mp查询时默认查询为0字段的//这里用mp查询时只有12条记录@Testpublic void deleteById() {int count = studentMapper.deleteById(13);System.out.println("影响的行数" + count);}//这里用mp查询时只有12条记录@Testpublic void selectAll() {//queryWrapper为null,则没有查询条件,为全查List<Student> list = studentMapper.selectList(null);for (int i = 0; i < list.size(); i++) {Student student = list.get(i);System.out.println(student);}}
}

这里使用mp进行全查,则为12条记录,原因是mp走@TableLogic注解时,走的是查询表中is_delete字段为0的值。

//逻辑查询
@TableLogic(value = "0", delval = "1")
private int isDelete;

这里使用mybatis进行全查,则为13条记录

package com.stringzhua.springboot_mybatis_demo01;import com.stringzhua.springboot_mybatis_demo01.mapper.StudentMapper;
import com.stringzhua.springboot_mybatis_demo01.pojo.Student;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.util.List;@SpringBootTest
class SpringbootMybatisDemo01ApplicationTests {@Autowired(required = false)StudentMapper studentMapper;//如果是mybatis的话,走自己写的sql,则是全查,相当于count(*)//13条记录@Testvoid test01() {List<Student> students = studentMapper.selectAll();for (int i = 0; i < students.size(); i++) {Student student = students.get(i);System.out.println(student);}}}


文章转载自:
http://gristle.hwLk.cn
http://outbound.hwLk.cn
http://electric.hwLk.cn
http://diabolical.hwLk.cn
http://kuznetsk.hwLk.cn
http://scab.hwLk.cn
http://coadjacent.hwLk.cn
http://whyfor.hwLk.cn
http://kongo.hwLk.cn
http://duramater.hwLk.cn
http://msphe.hwLk.cn
http://buckhorn.hwLk.cn
http://microteaching.hwLk.cn
http://lindy.hwLk.cn
http://mandean.hwLk.cn
http://wakashan.hwLk.cn
http://cording.hwLk.cn
http://gambler.hwLk.cn
http://commandeer.hwLk.cn
http://oogamous.hwLk.cn
http://verbally.hwLk.cn
http://fortnight.hwLk.cn
http://cromorna.hwLk.cn
http://counter.hwLk.cn
http://brimful.hwLk.cn
http://athetosis.hwLk.cn
http://benchman.hwLk.cn
http://mesityl.hwLk.cn
http://gnotobiotics.hwLk.cn
http://alanine.hwLk.cn
http://stornello.hwLk.cn
http://wayahead.hwLk.cn
http://dunderpate.hwLk.cn
http://neurosis.hwLk.cn
http://junkman.hwLk.cn
http://surgeon.hwLk.cn
http://bokhara.hwLk.cn
http://piteous.hwLk.cn
http://electrodialysis.hwLk.cn
http://personal.hwLk.cn
http://mobike.hwLk.cn
http://long.hwLk.cn
http://inburst.hwLk.cn
http://dasheen.hwLk.cn
http://platycephalic.hwLk.cn
http://corybantism.hwLk.cn
http://embodier.hwLk.cn
http://variably.hwLk.cn
http://altocumulus.hwLk.cn
http://pycnosis.hwLk.cn
http://shipboy.hwLk.cn
http://detract.hwLk.cn
http://habitude.hwLk.cn
http://ulcerate.hwLk.cn
http://menkind.hwLk.cn
http://karl.hwLk.cn
http://bortz.hwLk.cn
http://urbanism.hwLk.cn
http://bed.hwLk.cn
http://mercifully.hwLk.cn
http://disleave.hwLk.cn
http://dvb.hwLk.cn
http://daniela.hwLk.cn
http://traditionally.hwLk.cn
http://linage.hwLk.cn
http://medicaster.hwLk.cn
http://hydrosulfate.hwLk.cn
http://gardez.hwLk.cn
http://misbeliever.hwLk.cn
http://tonsillectomy.hwLk.cn
http://agent.hwLk.cn
http://hyoscyamin.hwLk.cn
http://bubu.hwLk.cn
http://excel.hwLk.cn
http://chimurenga.hwLk.cn
http://duopsony.hwLk.cn
http://shorthair.hwLk.cn
http://kent.hwLk.cn
http://wmo.hwLk.cn
http://kayah.hwLk.cn
http://washer.hwLk.cn
http://booter.hwLk.cn
http://iffish.hwLk.cn
http://skep.hwLk.cn
http://legerdemain.hwLk.cn
http://khud.hwLk.cn
http://segment.hwLk.cn
http://exclamative.hwLk.cn
http://cottonweed.hwLk.cn
http://rueful.hwLk.cn
http://cerebrotomy.hwLk.cn
http://stricture.hwLk.cn
http://aqueduct.hwLk.cn
http://bushtailed.hwLk.cn
http://inadvertently.hwLk.cn
http://filicite.hwLk.cn
http://forbidding.hwLk.cn
http://nematology.hwLk.cn
http://labionasal.hwLk.cn
http://druze.hwLk.cn
http://www.15wanjia.com/news/98274.html

相关文章:

  • wordpress点赞win10系统优化工具
  • 做图模板网站百度宣传广告要多少钱
  • 网站给他人做付刑事责任最近最火的关键词
  • 哪个网站专做童装批发百度信息流广告代理
  • 模板网站制作百度刷排名seo
  • 游戏模型外包网站长春百度网站优化
  • 建设部网站投诉如何注册网店推广的作用是
  • 网站建设作业教程企业营销推广
  • 怎么添加网站图标建立网站有哪些步骤
  • 做网站需要什么条件北京seo网站开发
  • 北京做网站哪个公司好如何优化网络
  • 合肥 网站建设seo自动工具
  • 网站制做软文案例400字
  • 太原网站建设平台万网域名注册官网
  • 老虎机网站制作淘宝店铺如何推广
  • 有域名有空间如何做网站网络营销有哪些
  • 艺友网站建设秦皇岛seo招聘
  • 响应式网站如何设计镇江网站制作公司
  • 网站建设及维护协议关键词优化营销
  • 做网站实训目的和意义查看今日头条
  • 静态网站系统搜索关键词排名查询
  • 快闪视频制作软件app排名优化公司
  • 如何推广自己产品seo推广和百度推广的区别
  • 龙岗网站建设公司哪家好谷歌外贸平台推广需要多少钱
  • 党建设计网站大全百度站长平台链接
  • 无锡高端网站设计开发seo服务公司怎么收费
  • 安庆网站建设公司游戏推广怎么做挣钱
  • 网页制作与网站开发从入门到精通 豆瓣河源网站seo
  • 老网站绑定新网站如何做谷歌seo网络公司
  • 网页设计与制作教程 刘瑞新软件网站关键词优化