1.使用mybatis-plus关于多模块自定义mapper找不到问题
结构
过程(teacherservice里自定义的mapper不生效)
①设置application.properties文件内容
路径换成你项目的路径
#配置mapper xml文件的路径
mybatis-plus.mapper-locations=classpath:com/neusoft/teacherservice/mapper/xml/*.xml
②启动类夹注解
@MapperScan("com.neusoft.teacherservice.mapper")
上述两个方法都未能生效(之前是好用的,自己瞎配置之后就废了)
最终
在teacherservice的pom文件中添加如下
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
解决了
2.thymleaf的th:text、href等如何拼接字符串和参数
<html lang="en" xmlns:th="http://www.thymleaf.org">
花括号里的内容为后台数据,在单引号里的为固定字符串。后台数据和死数据中间用加号连接,单引号和双引号交替使用。
th:text="${name}+' ,教师欢迎登录'"
带@的拼接,其中的问号是自己带的,不需要写进th里
th:href="@{/th/getImgByID(imgid=${imgitem.imgid})}"
http://******/th/getImgByID?imgid=1333742510706556930
th:action="@{'/th/'+${user.name}}"
th:action="@{/th/{name}(name=${user.name})}"
action="/th/用户名"
多个参数怎么拼接?
按照下边格式进行拼接,括号里为需要拼接的参数,
th:href="@{/th/wone(courid=${workitem.courid},workid=${workitem.workid})}"
前端显示如下
href="/th/wone?courid=1344912724370505729&workid=1344914006317506561"
3.配置thymleaf
①配置文件
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.mode=HTML5
②pom文件添加如下
maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>