索引.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%="This is First App" %>
</body>
</html>
web.xml 文件:
<display-name>JSPAPP</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
当我运行应用程序时 http://localhost:8080/JSPAPP/index.jsp使用它的工作正常但我已将此 URL 更改为 http://localhost:8080/MyFirstApp/index.jsp即我必须将 JSPAPP 更改为 MyFirstApp 我将如何更改请告诉我。
最佳答案
1) 如果您使用 eclipse 运行应用程序,则从项目“Properties --> Web Project Settings --> Context Root”更改上下文根。
2) 如果您要将应用程序部署到服务器(比如 tomcat),请将您的 war 文件重命名为您想要的上下文根目录。
关于java - 如何在 Jsp 或 Servlet 中更改请求 URl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31111452/