Java 如何在IntelliJ中配置TomCat及其工件以显示与autogen不同的jsp(通过SpringMVC);jsp";?

Java 如何在IntelliJ中配置TomCat及其工件以显示与autogen不同的jsp(通过SpringMVC);jsp";?,java,spring,eclipse,jsp,intellij-idea,Java,Spring,Eclipse,Jsp,Intellij Idea,我一直在上Udemy的春季课程,讲师使用Eclipse-JEE,因为它是免费的。然而,我最近得到了IntelliJ IDEA终极版,当然我更愿意使用它。我启动了一个新的SpringMVC项目,我发现配置Tomcat有一个额外的步骤,即添加一个EclipseJee似乎并不关心的工件(我觉得这对找到解决方案可能很重要)。我不知道这是什么,所以我只使用Web应用程序爆炸工件。使用的URL为。当我运行Tomcat服务器时,这个URL会自动显示index.jsp。这是我的问题。我希望它显示一个不同的jsp

我一直在上Udemy的春季课程,讲师使用Eclipse-JEE,因为它是免费的。然而,我最近得到了IntelliJ IDEA终极版,当然我更愿意使用它。我启动了一个新的SpringMVC项目,我发现配置Tomcat有一个额外的步骤,即添加一个EclipseJee似乎并不关心的工件(我觉得这对找到解决方案可能很重要)。我不知道这是什么,所以我只使用Web应用程序爆炸工件。使用的URL为。当我运行Tomcat服务器时,这个URL会自动显示index.jsp。这是我的问题。我希望它显示一个不同的jsp文件。即
web/web-INF/view/
中的main-menu.jsp。让我再解释一下

我有一个用
@Controller
注释的
HomeController
类,还有一个将“主菜单”作为
字符串返回的方法,通过
dispatcherservlet.xml
,Spring将在
WEB-INF/view/
之前加上
.jsp
。理论上,这应该显示
WEB-INF/view/
中的main-menu.jsp页面。但是,
index.jsp
在默认情况下始终显示,我甚至无法获得导航到
main menu.jsp
的链接。我觉得与用于分解工件的URL和返回“主菜单”的我的
HomeController
中带注释的
@RequestMapping(“/”)方法不一致

该程序在EclipseJEE中运行良好。我的直觉是,我需要更多地配置Tomcat服务器和Web应用程序分解工件,但我对工件一无所知,IntelliJ文档解释了工件,就像您已经知道工件是什么一样。有人在IntelliJ IDEA专业版中使用过Spring MVC吗?如何正确配置服务器以响应我的
@RequestMapping
?如果可能的话,我想让
@RequestMapping
保持原样,以便在课程中更容易理解。 以下是项目结构和所有相关文件


从项目中删除
index.jsp
文件。它的优先级高于请求映射


没有任何会被视为默认页面的文件(
index.html
index.jsp
default.html
,等等)。

我既放心又恼火。那是我生命中的几个小时,我一直在挖掘配置文件,我永远也找不到了。无论如何,谢谢你的帮助。这比我想象的要简单得多
<?xml version="1.0" encoding="UTF-8"?>
   <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web- 
   app_3_1.xsd"
         id="WebApp_ID" version="3.1">

    <display-name>DisplayName</display-name>

    <absolute-ordering/>

    <!-- Spring MVC Configs -->

    <!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- Step 3: Add support for component scanning -->
    <context:component-scan base-package="com.luv2code.springdemo" />

    <!-- Step 4: Add support for conversion, formatting and validation support -->
    <mvc:annotation-driven/>

    <!-- Step 5: Define Spring MVC view resolver -->
    <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/view" />
        <property name="suffix" value=".jsp" />
    </bean>

</beans>
package com.luv2code.springdemo.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HomeController {
    @RequestMapping("/")
    public String showPage() {
        return "main-menu";
    }
}