更新
This commit is contained in:
@@ -39,7 +39,7 @@ public class UploadHandleServlet extends HttpServlet {
|
|||||||
|
|
||||||
//得到上传文件的保存目录,将上传的文件存放于WEB-INF目录下,不允许外界直接访问,保证上传文件的安全
|
//得到上传文件的保存目录,将上传的文件存放于WEB-INF目录下,不允许外界直接访问,保证上传文件的安全
|
||||||
String savePath = this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload");
|
String savePath = this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload");
|
||||||
savePath= this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload").replace("\\out\\artifacts\\hellogithub_war_exploded\\WEB-INF\\upload","\\web\\uploadFile");
|
savePath= this.getServletContext().getRealPath(File.separator+"WEB-INF"+File.separator+"upload").replace("\\out\\artifacts\\helloGithub_war_exploded\\WEB-INF\\upload","\\web\\uploadFile");
|
||||||
System.out.println(savePath);
|
System.out.println(savePath);
|
||||||
// savePath="D:\\Java\\helloG\\hellogithub\\web\\uploadFile";
|
// savePath="D:\\Java\\helloG\\hellogithub\\web\\uploadFile";
|
||||||
// String savePath="E:\\Desktop\\out";
|
// String savePath="E:\\Desktop\\out";
|
||||||
|
@@ -3,11 +3,11 @@ package com.hellogithub.servlet;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hellogithub.entity.userEntity;
|
import com.hellogithub.entity.userEntity;
|
||||||
import com.hellogithub.service.UserService;
|
import com.hellogithub.service.UserService;
|
||||||
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 jakarta.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@@ -3,4 +3,13 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||||
version="4.0">
|
version="4.0">
|
||||||
|
<!-- 引⼊Tomcat的默认Servlet来处理静态资源 -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>default</servlet-name>
|
||||||
|
<url-pattern>*.jpg</url-pattern>
|
||||||
|
<url-pattern>*.css</url-pattern>
|
||||||
|
<url-pattern>*.png</url-pattern>
|
||||||
|
<url-pattern>*.gif</url-pattern>
|
||||||
|
<url-pattern>*.js</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
</web-app>
|
</web-app>
|
Reference in New Issue
Block a user