IDEA deploy Tomcat Tutorial (thorough understanding of the operation)

This article talk about the deployment of the IDEA set Tomcat to help you understand the whole process, is no longer the kind of talk about how online tutorial Why do not speak.
Are done in frameshot cut in Linux, so do not wonder why is /home/not the D:\
author of this article yucloud.cnblogs.com , reprint please indicate the source and the apparent position where Reprinted from






IDEA control on the Tomcat deployment, we must understand in detail the role of the various options:

First we look at IDEA in the current project structure configuration

File -》 Project Structure

Set Web resource directory and Tomcat web.xml configuration file read

To let Tomcat then reads the Web resources we need
to set about Web resources and web.xml configuration file path

-> Facets -> point plus add -> Web

Note: This Web resource directory is set to the root directory "/", actually refers to 部署目录的根目录(ie, in the case under Photo, noted that The following directories)

And then point Artifacts, here familiar with it? Here is part of Tomcat deployment settings

If you need module (of course, the Eclipse project called) in some of the files, you can right-click the Available Elementsmodule under (such as right figure servlet2Spring, select Put Into Output Root)

The Tomcat Run / Debug Configuration

Click on the menu bar under Edit Configurations ... (I narrowed the window, so the left side, but are generally on the right)









Deal with common problems

Let's deal with some common issues

Web resources can not be found

Such as html jsp css js-peer file directory is not deployed in IDEA

检查 Facets 里是否有 Web,并且各种路径配置是否正确

我想把项目下的 README.md 也放到部署目录

可以右击 Available Elements下的模块(如右击图中的 servlet2Spring,选择 Put Into Output Root更多详见标题2

上传文件失败 404 错误

不止是上传文件错误,很多 404 问题都应该按如下步骤检查
检查一下你设置的 http 路径是否可以访问,用 GET/POST 工具试一下

比较有可能是你设置的 Tomcat 路径是 例如http://localhost:8080/Demo_war_exploded 但是你用的上传路径是 http://localhost:8080/upload

  • 这时候要么把上传路径改为http://localhost:8080/Demo_war_exploded/upload
  • 要么把 Tomcat Run/Debug 配置的 URL 改为 http://localhost:8080/ 并设置 Application Context 为"/" 更多详见标题3
    比较可能是

Guess you like

Origin www.cnblogs.com/yucloud/p/11291607.html