Commit 51bfb1cd by 罗承锋

调整图片路径

parent 3288ad21
...@@ -20,12 +20,17 @@ import java.io.IOException; ...@@ -20,12 +20,17 @@ import java.io.IOException;
@RestController @RestController
public class ImgController { public class ImgController {
/**
* 服务器访问路径
*/
private static String pathPre = "/springboot/school_center/manager/";
//menuname = "图片路径" 只支持jpeg 和 png //menuname = "图片路径" 只支持jpeg 和 png
@RequestMapping( value = "/images/**",produces ={MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_PNG_VALUE} ) @RequestMapping( value = "/images/**",produces ={MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_PNG_VALUE} )
public byte[] getbackground(HttpServletRequest request) { public byte[] getbackground(HttpServletRequest request) {
byte[] bytes=new byte[10]; byte[] bytes=new byte[10];
request.getServletPath(); request.getServletPath();
String imgurl= FilePath.BACKGROUNDIMG.getValue()+"/"+request.getServletPath(); String imgurl= pathPre + FilePath.BACKGROUNDIMG.getValue()+"/"+request.getServletPath();
imgurl = imgurl.replace("//", "/"); imgurl = imgurl.replace("//", "/");
File file = new File(imgurl); File file = new File(imgurl);
FileInputStream inputStream = null; FileInputStream inputStream = null;
......
...@@ -20,6 +20,11 @@ import java.util.Date; ...@@ -20,6 +20,11 @@ import java.util.Date;
public class PicturesUtil { public class PicturesUtil {
/** /**
* 上传路径
*/
private static String UPLOAD_PRE = "/springboot/school_center/manager/";
/**
* 上传图片 * 上传图片
* <p> * <p>
* 前端传来图片必须为jpeg格式 * 前端传来图片必须为jpeg格式
...@@ -55,7 +60,7 @@ public class PicturesUtil { ...@@ -55,7 +60,7 @@ public class PicturesUtil {
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
}//enclosure/images/idCard/temp/年/月/日/name.jpeg }//enclosure/images/idCard/temp/年/月/日/name.jpeg
filePath = FilePath.PATH.getValue()+ pathType+ "/" + yymmdd + "/" + orderNum + "/" + (new Date()).getTime() + "." + PicturesUtil.checkSuffix(houzhui); filePath = UPLOAD_PRE + FilePath.PATH.getValue()+ pathType+ "/" + yymmdd + "/" + orderNum + "/" + (new Date()).getTime() + "." + PicturesUtil.checkSuffix(houzhui);
//byte[] bytes = Base64.getUrlDecoder().decode(base64Data); //byte[] bytes = Base64.getUrlDecoder().decode(base64Data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment