我正在使用 IntelliJ 并導入了 Spring MVC 項目。我配置了 Maven 設置并用于mvn clean install 構建我的項目。為了運行,我在 IntelliJ 的配置上配置了 tomcat:run。但紅色標記顯示為:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.luv2code</groupId> <artifactId>spring-security-demo</artifactId> <version>1.0</version> <packaging>war</packaging> <name>spring-security-demo</name> <properties> <springframework.version>5.0.2.RELEASE</springframework.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <!-- Spring MVC support --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${springframework.version}</version> </dependency> <!-- Servlet, JSP and JSTL support --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies>
2 回答

心有法竹
TA貢獻1866條經驗 獲得超5個贊
嘗試這樣做:
File->Project Structure->Modules->檢查是否添加了 Web 模塊
如果“否”:
1. 添加此模塊。然后查看第 2 點。
如果“是”:
檢查那里的Web 資源目錄:
2。它必須指向您的webapp目錄路徑。

揚帆大魚
TA貢獻1799條經驗 獲得超9個贊
在你的 DemoController showHome 中應該返回一個 ModelAndView 這樣的東西然后 ViewResolver 將它映射到home.jsp
@RequestMapping("/")
public ModelAndView showHome() {
? ? return new ModelAndView("home");
}
添加回答
舉報
0/150
提交
取消