注册用户时,数据库将存储图像的url。
@RequestMapping("/addMembers")
public String addMembers(@ModelAttribute(value = "member") Members member, @RequestParam("file") MultipartFile file, HttpServletRequest request,HttpSession session) {
Integer flag = 0 ;
try {
if (!file.isEmpty()) {
String fileName = file.getOriginalFilename();
member.setMprofile("/upload/member/" + member.getMemacc() + "/" + fileName);
String filePath = "C:/Users/jpg74/IdeaProjects/jason/src/main/resources/static/upload/member/"+member.getMemacc() + "/";
File destination = new File(filePath + fileName);
if(!destination.exists()){
destination.mkdirs();
}
try {
file.transferTo(destination);
logger.info("" +
"Upload Success!!!");
} catch (IOException e) {
logger.error(e.toString(), e);
}
}
flag = memberMapper.addMember(member);
} catch (Exception e) {
logger.error(e.toString(), e);
}
if(flag > 0)
return "front-end/login/login";
else
return "404";
}
然后用户希望在其个人资料中显示信息。但是即使图像的url是正确的,图像也不能正确读取。
<figure id='a_mprofile'>
<img id='mprofile' class="pimg" th:src="${ member.getMprofile()}">
</figure>
我寻找解决方案,比如从https://dev.to/suin/spring-boot-developer-tools-how-to-enable-automatic-restart-in-intellij-idea-1c6i.
现在我必须按ctrl+f9刷新tomcat。我怎样才能解决这个问题。谢谢您!!!
暂无答案!
目前还没有任何答案,快来回答吧!