Tomcat direct IP address access without adding a port or project name
After we develop a web project and deploy it to Tomcat, we should normally access: http: // localhost: Port Number/Project Name
If we want users to only enter the domain name to access our project, we need to modify the context settings of Tomcat.
Modify{Tomcat_home}/CONF/server. xmlFile
Open the server. xml file in the text editor.<Host>Add under Node<Context>Node, and setPath, docbase, reloadableAttribute
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/" docBase="/projectName" reloadable="false"/> </Host>
<Context> attributes of an element:
Path: Specifies the URL entry to access the Web application. Path = "/" or Path = ""
Docbase: Specifies the file path of the Web application.Absolute pathYou can also specify the appbase attribute relative to the Relative Path,
If the web application adopts an open directory structure, specify the root directory of the Web application. If the web application is a war file, specify the path of the war file.
This can be the relative path: docbase = "/projectname" or absolute path: docbase = "D: \ Tomcat \ webapps \ projectname"
Reloadable: If this property is set to true, the Tomcat server will monitor changes to the class files in the WEB-INF/classes and WEB-INF/lib directories while running,
If a class file is detected to be modified, the server automatically reloads the web application.
Itmyhome
Configuration of context in Tomcat