Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
aba400d3
Commit
aba400d3
authored
Mar 09, 2020
by
吴学德
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片加载功能
parent
56afdc89
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
apply-net/src/main/java/com/winsun/controller/ImgController.java
+50
-0
No files found.
apply-net/src/main/java/com/winsun/controller/ImgController.java
0 → 100644
View file @
aba400d3
package
com
.
winsun
.
controller
;
import
com.winsun.constant.FilePath
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
/**
* @Author xuede
* @Date 2020/3/6 16:44
* @Version 1.0
*/
@Slf4j
@RestController
public
class
ImgController
{
//menuname = "图片路径" 只支持jpeg 和 png
@RequestMapping
(
value
=
"/images/**"
,
produces
={
MediaType
.
IMAGE_JPEG_VALUE
,
MediaType
.
IMAGE_PNG_VALUE
}
)
public
byte
[]
getbackground
(
HttpServletRequest
request
)
{
byte
[]
bytes
=
new
byte
[
10
];
request
.
getServletPath
();
String
imgurl
=
FilePath
.
BACKGROUNDIMG
.
getValue
()+
"/"
+
request
.
getServletPath
();
imgurl
=
imgurl
.
replace
(
"//"
,
"/"
);
File
file
=
new
File
(
imgurl
);
FileInputStream
inputStream
=
null
;
try
{
inputStream
=
new
FileInputStream
(
file
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
try
{
bytes
=
new
byte
[
inputStream
.
available
()];
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
inputStream
.
read
(
bytes
,
0
,
inputStream
.
available
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
bytes
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment