刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 1 | package com.pt5.pthouduan.config; |
| 2 | |
| 3 | import org.springframework.context.annotation.Configuration; |
| 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| 6 | |
| 7 | @Configuration |
| 8 | public class WebMvcConfig implements WebMvcConfigurer { |
| 9 | |
| 10 | @Override |
| 11 | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
21301050 | f5f827d | 2025-06-09 15:09:33 +0800 | [diff] [blame^] | 12 | // 帖子图片:D:/postuploads/ → /images/** 求助帖 |
| 13 | registry.addResourceHandler("/activityimgs/**") |
| 14 | .addResourceLocations("file:./activityimgs/");//路径改一下 |
| 15 | // 帖子图片:D:/postuploads/ → /images/** 求助帖 |
| 16 | registry.addResourceHandler("/helppostimgs/**") |
| 17 | .addResourceLocations("file:./helppostimgs/");//路径改一下 |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 18 | |
| 19 | // ✅ 求助帖图片:D:/uploads/ → /uploads/** |
21301050 | f5f827d | 2025-06-09 15:09:33 +0800 | [diff] [blame^] | 20 | // 映射到项目根目录下的postimgs目录,这是帖子的 |
| 21 | registry.addResourceHandler("/postimgs/**") |
| 22 | .addResourceLocations("file:./postimgs/"); |
| 23 | |
| 24 | registry.addResourceHandler("/coverimgs/**") |
| 25 | .addResourceLocations("file:./coverimgs/"); |
| 26 | |
| 27 | registry.addResourceHandler("/userimgs/**") |
| 28 | .addResourceLocations("file:./userimgs/"); |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | |
| 32 | } |
| 33 | |