大家好,又见面了,我是你们的朋友全栈君。
针对以上两个问题,分步解决
问题一:IDEA社区版没有创建Web工程的选项
创建普通的java项目,此处不再赘述
构建web项目的目录结构
设置编译目录
在WEN-INF文件夹下新建web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="4.0" 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_4_0.xsd">
<display-name>xss</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
此时 http://xmlns.jcp.org/xml/ns/javaee 和 http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd 会报红,原因是没有web.xml的约束文件。tomcat的lib中包含所需的约束文件,因此在问题二中将得到解决。
问题二:安装Tomcat插件
说明: Deployment Directory: 项目部署的用到的文件夹 Context Path: / 表示访问项目时直接访问localhost即可,不用带上项目名 Server Port: 改成80端口访问项目时不用输入端口号了
添加之后web.xml的报红也会解决
至此,web项目已构建完毕,随后可以创建Servlet并访问成功
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/190826.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有