feat: support jetty shell generate

This commit is contained in:
ReaJason
2024-12-07 20:17:40 +08:00
parent b6e6b69339
commit a7cee2ea21
37 changed files with 1642 additions and 135 deletions
@@ -0,0 +1,22 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author ReaJason
* @since 2024/12/7
*/
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
}
}
@@ -28,7 +28,7 @@ public class UploadServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Part file = request.getPart("file");
String fileName = getFileName(file);
String uploadPath = getServletContext().getRealPath(UPLOAD_DIRECTORY) + fileName;
String uploadPath = getServletContext().getRealPath(UPLOAD_DIRECTORY) + File.separator + fileName;
InputStream inputStream = file.getInputStream();
File uploadFile = new File(uploadPath);
IOUtils.copy(inputStream, Files.newOutputStream(uploadFile.toPath()));
@@ -10,6 +10,15 @@
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
<!-- 用于 JSP 文件上传-->
<servlet>
<servlet-name>upload</servlet-name>