提交 91aa7862 authored 作者: noelgrandin's avatar noelgrandin

simplify code a little

上级 7f79b084
...@@ -91,7 +91,8 @@ public class WebServlet extends HttpServlet { ...@@ -91,7 +91,8 @@ public class WebServlet extends HttpServlet {
file = file.substring(1); file = file.substring(1);
} }
file = getAllowedFile(req, file); file = getAllowedFile(req, file);
byte[] bytes = null;
// extract the request attributes
Properties attributes = new Properties(); Properties attributes = new Properties();
Enumeration<?> en = req.getAttributeNames(); Enumeration<?> en = req.getAttributeNames();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {
...@@ -105,6 +106,7 @@ public class WebServlet extends HttpServlet { ...@@ -105,6 +106,7 @@ public class WebServlet extends HttpServlet {
String value = req.getParameter(name); String value = req.getParameter(name);
attributes.put(name, value); attributes.put(name, value);
} }
WebSession session = null; WebSession session = null;
String sessionId = attributes.getProperty("jsessionid"); String sessionId = attributes.getProperty("jsessionid");
if (sessionId != null) { if (sessionId != null) {
...@@ -125,7 +127,7 @@ public class WebServlet extends HttpServlet { ...@@ -125,7 +127,7 @@ public class WebServlet extends HttpServlet {
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return; return;
} }
bytes = server.getFile(file); byte[] bytes = server.getFile(file);
if (bytes == null) { if (bytes == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND); resp.sendError(HttpServletResponse.SC_NOT_FOUND);
bytes = StringUtils.utf8Encode("File not found: " + file); bytes = StringUtils.utf8Encode("File not found: " + file);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论