Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 Resin webserevr。有很棒的 FileServlet 类用于提供静态内容。我想重新映射 URI,例如
/user1/file.txt -> /users/dir1/1/file.txt /user2/file.txt -> /users/dir2/22/file.txt ...
在运行时。
但是用户名->路径映射不是静态的,并且基于一些数据库数据。
您可以将 /user URL 映射到 servlet,然后将请求转发到 Resin 的 FileServlet
final String actualFilePath = dao.getFilePathFor("/user1/file.txt"); final RequestDispatcher disp = request.getRequestDispatcher("/mystaticmapping" + actualFilePath); disp.include(request, response);