Java 8 App Engine 在 Eclipse 中运行,@WebServlet 不起作用。

huangapple 未分类评论54阅读模式
英文:

Java 8 App Engine Running in Eclipse, @WebServlet not working

问题

以下是您要翻译的内容:

我正在Eclipse内部运行App Engine标准版。

我的两个“servlet”使用“@WebServlet”可以工作,但另外3个则不行。
这个可以工作:

com.ifmrestoration.corrigo.CustomFieldServlet
@SuppressWarnings("serial")
@WebServlet(name = "CFAAppEngine", urlPatterns = { "/customfields" })
public class CustomFieldServlet extends HttpServlet {

这个则不行:

com.ifmrestoration.webscraper.ImageDownloaderServlet
@WebServlet(name = "DownloadServer", urlPatterns = { "/corrigoimagesdownload" })
public class ImageDownloaderServlet extends HttpServlet {

以下是web.xml内容:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
英文:

I am running App Engine Standard inside of Eclipse

Two of my "servlets" work using "@WebServlet" but 3 do not.
This works:

com.ifmrestoration.corrigo.CustomFieldServlet
@SuppressWarnings(&quot;serial&quot;)
@WebServlet(name = &quot;CFAAppEngine&quot;, urlPatterns = { &quot;/customfields&quot; })
public class CustomFieldServlet extends HttpServlet {

This doesn't:

com.ifmrestoration.webscraper.ImageDownloaderServlet
@WebServlet(name = &quot;DownloadServer&quot;, urlPatterns = { &quot;/corrigoimagesdownload&quot; })
public class ImageDownloaderServlet extends HttpServlet {

Here is the web.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd&quot;
         version=&quot;3.1&quot;&gt;
  &lt;welcome-file-list&gt;
    &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
    &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;

&lt;/web-app&gt;

答案1

得分: 0

你需要同时使用 web.xmlappengine-web.xml,如果你正在使用使用Java的GAE标准环境,因为它们用于描述应用程序的配置方式。
你可以查看文档以了解哪些配置设置适用于你的应用程序。

英文:

You need both the web.xml and appengine-web.xml if you are using GAE standard with Java as they are used to describe how your app is configured.
You can see the documents for details on which configuration setting you need for your application.

huangapple
  • 本文由 发表于 2020年5月30日 06:37:30
  • 转载请务必保留本文链接:https://java.coder-hub.com/62095564.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定