Spring MVC project, a project name that differs from the Tomcat path using the jetty plugin

Source: Internet
Author: User

Pom.xml:

Jetty Plug-in configuration:

<plugin>                <groupId>Org.mortbay.jetty</groupId>                <Artifactid>Maven-jetty-plugin</Artifactid>                <version>6.1.5</version>                <Configuration>                    <Scanintervalseconds>1</Scanintervalseconds>                    <webappsourcedirectory>Src/main/webapp</webappsourcedirectory>                    <Scanintervalseconds>3</Scanintervalseconds>                    <contextPath>/</contextPath>                    <Connectors>                        <connectorImplementation= "Org.mortbay.jetty.nio.SelectChannelConnector">                            <Port>8088</Port>                        </connector>                    </Connectors>                </Configuration>            </plugin>

Welcomepage:

@Controller @requestmapping ("/") Public classWelcomepage { PublicString Index () {return".. /index "; } @RequestMapping ("Index")     PublicString Index2 () {return"Index"; } @RequestMapping ("Login")     PublicString Login () {return"Index"; } @RequestMapping ("Calctime")     PublicString init () {return"/calctime/calctime"; }}

It used to be a project started with the MAVEN command, and it was a little strange to use it when accessing:

Localhost:8088/index

You can access the page, the other pages are similar, and you do not need to use the project name.

----------------------Split Line------------------------------

Yesterday, a VPS, the project was deployed, using the Tomcat

Tomcat starts normally and is not saved, but it is not connected to the server.

With a try mentality, add a project name

Ip:8080/project_name/index

The access is OK, but the other pages are not open.

The error is 404 and cannot be found.

Check to see that all requests are not with the project name , and of course the URL will not have the project name.

Nature is not accessible.

Plus the project name, the other connection access is normal.

is preparing to change, suddenly found that in the local and can not access.

This is embarrassing, without the project name, the server can not access, add the project name, local and not access .

It suddenly occurred to me that the development was using jetty, deployed with Tomcat.

Previous projects, also useless such a problem.

Never be too foolish.

Look at the configuration of the jetty:

<plugin>                <groupId>Org.mortbay.jetty</groupId>                <Artifactid>Maven-jetty-plugin</Artifactid>                <version>6.1.5</version>                <Configuration>                    <!--Hot Deploy -                    <Scanintervalseconds>1</Scanintervalseconds>                    <webappsourcedirectory>Src/main/webapp</webappsourcedirectory>                    <Scanintervalseconds>3</Scanintervalseconds>                    <contextPath>/project_name</contextPath> <!--The name of the war package--                    <Connectors>                        <connectorImplementation= "Org.mortbay.jetty.nio.SelectChannelConnector">                            <Port>8088</Port>                        </connector>                    </Connectors>                </Configuration>            </plugin>

Change, the ContextPath configuration is good.

In this way, the project's access path is added with the project name, consistent on the local and server, and enjoyable to play.

Spring MVC project, a project name that differs from the Tomcat path using the jetty plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.