更新
This commit is contained in:
@@ -37,11 +37,8 @@ public class retUserAvServlet extends HttpServlet {
|
|||||||
if(userEntity != null)
|
if(userEntity != null)
|
||||||
{
|
{
|
||||||
String uri = userEntity.getUserAvatar();
|
String uri = userEntity.getUserAvatar();
|
||||||
if(!uri.startsWith("https"))
|
|
||||||
{
|
|
||||||
FileInputStream fis = new FileInputStream (uri);
|
FileInputStream fis = new FileInputStream (uri);
|
||||||
String type = userEntity.getUserAvatar().substring(userEntity.getUserAvatar().lastIndexOf(".")+1);
|
String type = userEntity.getUserAvatar().substring(userEntity.getUserAvatar().lastIndexOf(".")+1);
|
||||||
|
|
||||||
int size = fis.available();
|
int size = fis.available();
|
||||||
if(size != 0)
|
if(size != 0)
|
||||||
{
|
{
|
||||||
@@ -54,21 +51,7 @@ public class retUserAvServlet extends HttpServlet {
|
|||||||
os.write(data);
|
os.write(data);
|
||||||
os.flush();
|
os.flush();
|
||||||
os.close();
|
os.close();
|
||||||
}
|
|
||||||
}else{
|
|
||||||
PrintWriter writer = resp.getWriter();
|
|
||||||
resp.setCharacterEncoding("UTF-8");
|
|
||||||
resp.setContentType("text/html; charset=utf-8");
|
|
||||||
// 设置响应头允许ajax跨域访问
|
|
||||||
String curOrigin = req.getHeader("Origin");
|
|
||||||
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
|
||||||
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
|
||||||
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
|
||||||
resp.setHeader("Access-Control-Max-Age", "3600");
|
|
||||||
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
|
||||||
resp.setContentType("application/json;charset=UTF-8");
|
|
||||||
writer.println(uri);
|
|
||||||
writer.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package com.hellogithub.servlet;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hellogithub.service.projectService;
|
import com.hellogithub.service.projectService;
|
||||||
import jakarta.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
Reference in New Issue
Block a user