[英]Why is every url “redirecting” to the welcome-file url?
Servlets 小程序
@WebServlet("/")
public class AServlet extends HttpServlet {
-- loads an .jsp
and displays "AServlet" -加载.jsp
并显示“ AServlet”
@WebServlet("/b")
public class BServlet extends HttpServlet {
-- returns an simple JSON -返回一个简单的JSON
index.html index.html
-- displays "Not a JSP" -显示“不是JSP”
web.xml web.xml
...
<welcome-file-list>
<welcome-file>/</welcome-file>
</welcome-file-list>
...
Every url that doesn't match an servlet executes the same action as the A servlet. 每个与servlet不匹配的url都执行与A servlet相同的操作。
Eg: 例如:
将Servlet映射到“ /”使其成为默认Servlet,这意味着它将处理所有与任何其他映射都不匹配的请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.