图片路径转发
This commit is contained in:
parent
7d7ccce242
commit
a863c372fc
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.ServletInputStream;
|
import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -143,6 +144,7 @@ public class EventController {
|
||||||
@GetMapping("selectEvent")
|
@GetMapping("selectEvent")
|
||||||
@ApiOperation("查询所有事件")
|
@ApiOperation("查询所有事件")
|
||||||
public Result selectEvent(){
|
public Result selectEvent(){
|
||||||
|
|
||||||
List<Event> events = eventMapper.selectEvent();
|
List<Event> events = eventMapper.selectEvent();
|
||||||
|
|
||||||
Result success = Result.success(events);
|
Result success = Result.success(events);
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.hisense.monitormanage.controller;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class FordController {
|
||||||
|
|
||||||
|
@GetMapping("components/**")
|
||||||
|
@ApiOperation("查询所有事件")
|
||||||
|
public void ford(HttpServletRequest request, HttpServletResponse response)throws Exception{
|
||||||
|
|
||||||
|
String imageDomain = "http://10.132.191.48:30080";
|
||||||
|
|
||||||
|
String uri = request.getRequestURI();
|
||||||
|
String fordUrl = imageDomain + uri;
|
||||||
|
|
||||||
|
URLConnection con = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
URL url = new URL(fordUrl);
|
||||||
|
con = url.openConnection();
|
||||||
|
|
||||||
|
//允许写出
|
||||||
|
con.setDoOutput(true);
|
||||||
|
//允许读入
|
||||||
|
con.setDoInput(true);
|
||||||
|
//不使用缓存
|
||||||
|
con.setUseCaches(false);
|
||||||
|
//得到响应流
|
||||||
|
InputStream inputStream = con.getInputStream();
|
||||||
|
|
||||||
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len = inputStream.read(buffer);
|
||||||
|
while (len != -1) {
|
||||||
|
outputStream.write(buffer, 0, len);
|
||||||
|
len = inputStream.read(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue