Apache tomcat服务器本地主机url

时间:2017-11-17 08:58:22

标签: java apache tomcat server

当我在eclipse中使用tomcat服务器运行我的应用程序时,我将被重定向到以下URL:"HTTP://localhost:8080/example/login"

/login是我的控制器请求映射,但example也会被追加。如何从我的网址中删除它。

以下是我的server.xml

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
    <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

    <GlobalNamingResources>
        <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
    </GlobalNamingResources>

    <Service name="Catalina">

        <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>


        <Engine defaultHost="localhost" name="Catalina">

            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
            </Realm>

            <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>

                <Context docBase="sourcelead" path="/sourcelead" reloadable="true" source="org.eclipse.jst.jee.server:sourcelead"/><Context docBase="spring-mvc" path="/spring-mvc" reloadable="true" source="org.eclipse.jst.jee.server:spring-mvc"/></Host>
        </Engine>
    </Service>
</Server>

1 个答案:

答案 0 :(得分:0)

您应该在Eclipse中更改项目设置。

右键点击您的项目

-Properties

-Web项目设置

- 更改您的上下文路径

最后清理并重建您的项目。