我正在尝试创建一个 servlet 并将其部署到 SAP 云平台。对servlet根本不熟悉。
首先,我创建并部署了 Eclipse 生成的几乎所有内容作为示例应用程序
@WebServlet("/hello")
public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public HelloWorldServlet() {
super();
// TODO Auto-generated constructor stub
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().println("Hello World!");
}
}
然后,我部署它,我可以看到应用程序正在运行并且我有一个 URL。
我现在正尝试通过您在上面的屏幕截图中看到的 URL 从浏览器访问它。我认为我所要做的就是将 /hello
添加到它的末尾,然后我们就可以了。但它给出了 404。访问日志显示我正在访问该 servlet,但无法显示“hello world”:
有人知道这里的 URL 是什么意思吗?
编辑:
重新部署时,它开始捕获错误。只有初始部署似乎有效:
Problem during deploymentJava version [8] is not compatible with the currently specified runtime; use runtime neo-java-web 2.x or 3.x or neo-javaee7-wp 1.x
最佳答案
答案是不使用Eclipse中的“部署到sap云平台”选项,而是导出为WAR文件并选择Tomcat 8作为运行环境。之后,通过上传WAR文件手动更新SCP上的应用程序并重新启动正在运行的进程。
为我工作。
关于java - 访问SAP云平台上的Java Servlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47284580/