我想调用 Servlet
作为第一个文件来像欢迎文件一样执行。
在此 servlet 中,我从数据库检索数据并将其渲染到显示页面的第一页。
我需要的是当我运行程序时
要么
url should be-
http://localhost:8083/projectName/servletUrl
not
http://localhost:8083/projectName/
或
if url is
http://localhost:8083/projectName
this should hit myservlet(/servletUrl)
notwelcome file
.
最佳答案
编辑此文件WebContent
->WEB-INF
->lib
->web.xml
。
It will only be visible if you have ticked the Generate web.xml deployment descriptor while creating the project.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>Database_Conn</display-name>
<welcome-file-list>
<welcome-file>ServletURLpattern</welcome-file>
</welcome-file-list>
</web-app>
关于java - 我想将 Servlet 作为第一个文件调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30780313/