[外链图⽚转存失败,源站可能有防盗链机制,建议将图⽚保存下来直接上传(img-MmY445bN-三、SpringBoot Web开发
⾸页
jsp, 模板引擎Thymeleaf
thymeleaf依赖
装配扩展SpringMVC
增删改查
国际化
四、员⼯管理系统
1. ⾸页配置
1. 注意点,所有页⾯的静态资源都需要使⽤thymeleaf接管;(导⼊thymeleaf依赖)
2. url: @{}
2. 页⾯国际化
1. 我们需要配置i18n⽂件
2. 我们如果需要在项⽬中进⾏按钮⾃动切换,我们需要⾃定义⼀个组件LocaleResolver
3. 记得将⾃⼰写的组件配置到spring容器@Bean
4. #{}
五、整合MyBatis
整合包
mybatis-spring-boot-starter
1. 导⼊包
<span ><code class="language-xml"><span ><!--引⼊my
batis,这是Mybatis官⽅提供的适配SpringBoot的,⽽不是<span ><span ><span ><</span>dependency</span><span >></sp    <span ><span ><span ><</span>groupId</span><span >></span    <span ><span ><span ><</span>artifactId</span><span >></spa    <span ><span ><span ><</span>version</span><span >></span <span ><span ><span ></</span>dependency</span><span >></sp </code></span>
2. 配置yml⽂件
spring ioc注解
<span ><code class="language-yml"><span ># 配置spring⾃带的数据源</span>
<span >spring</span><span >:</span>
<span >datasource</span><span >:</span>
<span >username</span><span >:</span> root
<span >password</span><span >:</span> root
<span >url</span><span >:</span> jdbc<span >:</span>mysql<span color:#c678dd">driver-class-name</span><span >:</span> sql.cj.jdbc.Driver
<span ># 整合mybatis</span>
<span >mybatis</span><span >:</span>
<span ># 别名</span>
<span >type-aliases-package</span><span >:</span> com.kuang.pojo
<span ># mapper⽂件位置</span>
<span >mapper-locations</span><span >:</span> classpath<span >:</span>mybatis/ma </code></span>
3. mybatis配置
1. User
<span ><code class="language-java"><span >@Data</span>
<span >@AllArgsConstructor</span>
<span >@NoArgsConstructor</span>
<span >public</span> <span >class</span> User <span >{</span>
<span >private</span> <span >int</span> id<span >;</span>
<span >private</span> String name<span >;</span>
<span >private</span> String password<span >;</span>
<span >}</span>
</code></span>
2. UserMapper接⼝
<span ><code class="language-java"><span >@Repository</span>
<span >@Mapper</span>
<span >public</span> <span >interface</span> UserMapper <span >{</span>
<span >public</span> User <span >queryUserByName</span><span >(</span>S <span >}</span>
</code></span>
3. l配置⽂件
<span ><code class="language-xml"><span ><!--namespace=绑定⼀个指定的Dao/Mapper接⼝--></span> <span ><span ><span ><</span>mapper</span> <span >nam    <span ><span ><span ><</span>select</span> <span >id<    select * from USER where name = #{name}
<span ><span ><span ></</span>select</span><span >></ <span ><span ><span ></</span>mapper</span><span >></ </code></span>
4. 编写sql
5. service层调⽤dao层
1. UserService 接⼝
<span ><code class="language-java"><span >public</span> <span >interfac
<span >public</span> User <span >queryUserByName</span><span >(</span>S <span >}</span>
</code></span>
2. UserServiceImpl实现类
<span ><code class="language-java"><span >@Service</span>
<span >public</span> <span >class</span> UserServiceImpl <span >implements</s    <span >@Autowired</span>
UserMapper mapper<span >;</span>
<span >public</span> User <span >queryUserByName</span><span >(</span>S        User user <span >=</span> mapper<span >.</span><span >queryUserByNam        <span >return</span> user<span >;</span>
<span >}</span>
<span >}</span>
</code></span>
6. controller调⽤service层
<span ><code class="language-java"><span >@Autowired</span>
UserServiceImpl userService<span >;</span>
<span >public</span> <span >void</span> <span style=
"color:#61aeee">mian</span><span color:#669900">=</span> userService<span >.</span><span >queryUserByName</s <span >}</span>
</code></span>
六、SpringSecurity
1. 引⼊ Spring Security 模块
2. 编写 Spring Security 配置类
3. 编写基础配置类
1. 定制请求的授权规则
2. 定义认证规则
Realm 连接数据简单实验:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。