- session清除:
session.invalidate();
- thymeleaf日期格式设置:
${#dates.format(emp.getBirth(),'yyyy-MM-dd hh:mm:ss')}
- 前端传参:
@{'/emp/'+${emp.getId()}}
- 后端接收并使用:
@RequestMapping("/emp/{id}")
public String toUpdateEmp(@PathVariable("id") Integer id,Model model){
Employee employees = employeeDao.getEmployeeById(id);
model.addAttribute("emp",employees);
Collection<Department> departments = departmentDao.getDepartments();
model.addAttribute("departments",departments);
return "emp/update";
}
return "redirect:/index";
- thymeleaf 和shiro的整合引入链接 :
<html lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.thymeleaf.org/thymeleaf-extras-shiro">
- html返回上一页:
<a href="#" onclick="javascript:history.back(-1);"></a>
<a href="#" onclick="javascript:history.go(-1);"></a>
<a href="javascript:location.reload()">重载页面,本地刷新</a>
<a href="javascript:history.go(-1);location.reload()">返回上一页重载页面,本地刷新</a>
<a href="#" onclick="self.location=document.referrer;">返回</a>
- thymeleaf的超链接+ajax删除用户:
<a class="layui-icon" th:href="'javascript:del('+${user.userId}+');'" ></a>删除
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery.serializeJSON/2.9.0/jquery.serializejson.js"></script>
<script type="text/javascript">
function del(userId){
var pp = confirm("是否删除?");
if(pp){
var url = "/deleteUser";
var param = {userId:userId};
$.get(url,param,function(date){
if(date=="success"){
location.href="/queryUser"
}else {
alert("修改失败")
location.href="/queryUser"
}
});
}
}
</script>
- vue解决闪烁数据问题:
<style>
[v-cloak]{
display: none;
}
</style>
<div id="vue" v-cloak>
.....
</div>
- 快捷创建对象接收。
方法后+ .var
userMapper.selectList(null) .var ==> List<User> users = userMapper.selectList(null);
- 解决图片或者视频上传无法马上播放问题
bug原因
这是因为idea对服务器的保护措施导致的,服务器不能对外部暴露真实的资源路径,需要配置虚拟路径映射访问。
新建config包,添加配置类
@Configuration
public class FileUploadConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/upload/**").addResourceLocations("file:E:\\xxx\\study\\study\\src\\main\\resources\\static\\upload\\");
}
}