IntelliJ IDEA2019实现Web项目创建示例
作者:波波烤鸭 时间:2023-06-05 00:29:33
一、创建web项目
1、打开idea软件,点击界面上的Create New Project
2、进入如下界面。选中 java Enterprise,配置jdk,tomcat,勾选Web Application案例,注意勾选生成web.xml文件
3、指定项目的名称及项目文件的保存地址
4、创建成功
5、创建class文件和lib文件夹
点击项目的WEF-INF文件夹 ,右键,New → Directory 创建两个文件夹,classes(用来存放编译后输出的class文件) 和 lib(用于存放第三方jar包)
6、配置classes文件夹路径
File → 选择 Project Structure → 选择 Module → 选择Paths → 选择 “Use module compile output path” -> 将Output path和Test output path都选择刚刚创建的classes文件夹。
7、配置lib文件夹路径
点击Paths旁边的Dependencies 点击右边的”+”号 → 选择”Jars or Directories” -> 将Output path和Test output path都选择刚刚创建的classes文件夹 → 选择”Jar Directory” 然后一路OK就行了.
选择刚刚创建的lib文件夹
二、tomcat项目部署
1.配置tomcat
点击Run ,选择Edit Configurations.
点击右上角的三角形,运行
三、创建servlet
src–>New–>Create New Servlet
servlet中简单代码
/**
* 通过urlPatterns指定映射地址或者在web.xml文件中配置
*/
@WebServlet(name = "helloServlet",urlPatterns = {"/hello"})
public class HelloServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("hello serlvet");
request.getRequestDispatcher("/index.jsp").forward(request,response);
}
}
3.测试
运行tomcat访问测试:http://localhost:8080/hello
访问成功~到此idea中创建web项目搞定
来源:https://blog.csdn.net/qq_38526573/article/details/89743221
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C# 索引器的使用教程
使用JMX监控Zookeeper状态Java API
C#实现根据银行卡卡号判断银行名
![](https://img.aspxhome.com/file/2023/6/108706_0s.png)
Android三种GSM手机定位技术分析
c# 以二进制读取文本文件
C#多线程学习之(二)操纵一个线程的方法
Android学习之AppWidget笔记分享
![](https://img.aspxhome.com/file/2023/0/123320_0s.png)
Java传入用户名和密码并自动提交表单实现登录到其他系统的实例代码
commons fileupload实现文件上传的实例代码
![](https://img.aspxhome.com/file/2023/4/97794_0s.png)
Idea 搭建Spring源码环境的超详细教程
![](https://img.aspxhome.com/file/2023/9/132059_0s.jpg)
C#使用HttpClient的正确方式你了解吗
![](https://img.aspxhome.com/file/2023/1/129721_0s.png)
基于socket和javaFX简单文件传输工具
Android 7.0新特性详解
Java身份证验证方法实例详解
java实现日期拆分的方法
C++类中的六大默认成员函数详解
![](https://img.aspxhome.com/file/2023/1/129531_0s.png)
java 键盘输入一个数,输出数组中指定元素的示例
c# SqlDataAdapter中的Fill是怎么实现的
![](https://img.aspxhome.com/file/2023/2/98242_0s.png)