Related software: Intellij Idea2017, jdk16, tomcat7
Intellij Idea can be installed directly (you can choose the installation directory you set according to your needs), jdk can use 1.6/1.7/1.8, the main thing is to configure the system environment variables, download the compressed package from the official website of tomcat7 on tomcat7 and extract it.
1. Create a simple web project
1. Create a web project
File -> new Project -> select project sdk as 1.6 (if you don't have sdk, please configure it first) -> Next
create project from template page, uncheck any options -> Next
Enter the project name: webDemo -> Next -> Finish
2. Create a Module
Click on the project name webDemo -> right click and select New, select Module -> Module SDK, select 1.6 -> check Web Application (3.1) under JavaEE, note that the version under the window corresponds to 3.1, and Create web.xml is checked -> Next
Enter Module name as firstweb -> Finish
3. Create a good web project
4. Create two folders in the web/WEB_INF directory: classes and lib
classes are used to store the compiled class files, lib is used to store third-party jar packages
5. Configure the folder path
File -> Project Structure (ctrl + shift + Alt + s) or use the toolbar shortcut -> select Modules
-> Select Paths -> Select "Use module compile out path" -> Set both Outputpath and Test output path to the classes folder you just created
选择当前窗口的Dependencies -> 将Module SDK选择为1.6 ->点击右边的 + 号 -> 选择 “1 JARS or directories ...”
-> 选择刚刚创建的lib文件夹 -> OK
-> 选择Jar Directory -> OK
-> Apply -> OK
三、配置Tomcat容器
打开菜单Run -> Edit Configurations...
点击 “+” ,选择 “Tomcat Server” -> 选择“Local”
在Name出输入新的服务器名,点击 "Application Server" 后面的 "Configure...",弹出Application Servers窗口,在Tomcat Home 选择本地安装的tomcat目录 -> OK
在"Run/Debug Configurations"窗口中Name一栏输入服务器的名字tomcat7,在“Server”面板中,勾选取消“After Launch”,设置“HTTP port”和“JMX port”(默认值即可),点击Apply -> OK,至此tomcat配置完毕(左边列表中tomcat图标上小红叉是未部署项目的提示,部署项目后就会消失)。
四、在tomcat上部署并运行项目
在创建好tomcat后,可以通过工具栏快速打开tomcat的配置页面:
也可以通过菜单栏:Run -> Edit Configurations... ->选择刚创建的tomcat7 -> 选择Deployment ->点击右边的“ + ”号 -> 选择 Artifact
-> 选择web项目 -> Application Context可以填“/firstweb”(也可以不填) -> Apply
回到Server面板,将On 'update' action和On frame deactivation(这两个选项是tomcat配置了项目后才有的)改为update classes and resources -> Apply
开发web项目并运行tomcat查看效果
1、编辑index.jsp页面
2、运行tomcat
转载自:https://www.cnblogs.com/shindo/p/7272646.html