英文:
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("serial")
@WebServlet(name = "CFAAppEngine", urlPatterns = { "/customfields" })
public class CustomFieldServlet extends HttpServlet {
This doesn't:
com.ifmrestoration.webscraper.ImageDownloaderServlet
@WebServlet(name = "DownloadServer", urlPatterns = { "/corrigoimagesdownload" })
public class ImageDownloaderServlet extends HttpServlet {
Here is the 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>
答案1
得分: 0
你需要同时使用 web.xml 和 appengine-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.
专注分享java语言的经验与见解,让所有开发者获益!
评论