mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add logo
This commit is contained in:
@@ -212,7 +212,8 @@ public class StatViewServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRequireAuth() && session.getAttribute(SESSION_USER_KEY) == null
|
||||
if (isRequireAuth()
|
||||
&& session.getAttribute(SESSION_USER_KEY) == null
|
||||
&& !("/login.html".equals(path) || path.startsWith("/css") || path.startsWith("/js") || path.startsWith("/img"))) {
|
||||
if (contextPath == null || contextPath.equals("") || contextPath.equals("/")) {
|
||||
response.sendRedirect("/login.html");
|
||||
@@ -251,6 +252,15 @@ public class StatViewServlet extends HttpServlet {
|
||||
|
||||
private void returnResourceFile(String fileName, String uri, HttpServletResponse response) throws ServletException,
|
||||
IOException {
|
||||
if (fileName.endsWith(".jpg")) {
|
||||
byte[] bytes = IOUtils.readByteArrayFromResource(RESOURCE_PATH + fileName);
|
||||
if (bytes != null) {
|
||||
response.getOutputStream().write(bytes);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String text = IOUtils.readFromResource(RESOURCE_PATH + fileName);
|
||||
if (text == null) {
|
||||
response.sendRedirect(uri + "/index.html");
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package com.alibaba.druid.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
@@ -52,6 +54,37 @@ public class IOUtils {
|
||||
JdbcUtils.close(in);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] readByteArrayFromResource(String resource) throws IOException {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
|
||||
if (in == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
copy(in, output);
|
||||
return output.toByteArray();
|
||||
} finally {
|
||||
JdbcUtils.close(in);
|
||||
}
|
||||
}
|
||||
|
||||
public static long copy(InputStream input, OutputStream output)
|
||||
throws IOException {
|
||||
final int EOF = -1;
|
||||
|
||||
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
long count = 0;
|
||||
int n = 0;
|
||||
while (EOF != (n = input.read(buffer))) {
|
||||
output.write(buffer, 0, n);
|
||||
count += n;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String read(Reader reader) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user