Spring mvc 无法在STS中运行第二个Spring MVC应用程序。

Spring mvc 无法在STS中运行第二个Spring MVC应用程序。,spring-mvc,mapping,Spring Mvc,Mapping,我正在使用本教程: 使用Spring的工具套件3.0运行Spring MVC应用程序 当部署一个应用程序MVC并使用以下url时,它可以正常工作: 但是,如果我尝试使用以下url部署另一个项目: 它返回404页面未找到错误,控制台显示此错误消息: ARN:org.springframework.web.servlet.PageNotFound-在名为“appServlet”的DispatcherServlet中找不到URI为[/AnotherMvcProject/]的HTTP请求的映射 此外,日

我正在使用本教程:

使用Spring的工具套件3.0运行Spring MVC应用程序

当部署一个应用程序MVC并使用以下url时,它可以正常工作:

但是,如果我尝试使用以下url部署另一个项目:

它返回404页面未找到错误,控制台显示此错误消息:

ARN:org.springframework.web.servlet.PageNotFound-在名为“appServlet”的DispatcherServlet中找不到URI为[/AnotherMvcProject/]的HTTP请求的映射

此外,日志显示正在部署它:

Jan 3, 2012 2:24:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor AnotherMvcProject.xml from /Users/myname/springsource/vfabric-tc-server-developer-2.6.1.RELEASE/spring-insight-instance/conf/Catalina/localhost
以下是web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</param-value>
    </context-param>

    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>
除了包名之外,代码与BareMvc相同。xyz.sample.baremvc与xyz.mvc.project

我不清楚如何指定从应用程序名到servlet引擎的映射。看起来可能是项目pom.xml,但它们也是一致的:

groupId=xyz.sample
m2e.projectName=BareMvc

groupId=xyz.mvc
m2e.projectName=AnotherMvcProject

我被难住了。有什么想法吗

供将来参考-只需清理项目即可解决问题

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    /**
     * Simply selects the home view to render by returning its name.
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String home(Locale locale, Model model) {
        logger.info("Welcome home! the client locale is "+ locale.toString());

        Date date = new Date();
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

        String formattedDate = dateFormat.format(date);

        model.addAttribute("serverTime", formattedDate );

        return "home";
    }

}
groupId=xyz.sample
m2e.projectName=BareMvc

groupId=xyz.mvc
m2e.projectName=AnotherMvcProject