为了账号安全,请及时绑定邮箱和手机立即绑定

如何在Intellij中运行导入的Spring mvc项目?

如何在Intellij中运行导入的Spring mvc项目?

炎炎设计 2023-05-24 15:10:37
我正在使用 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目录路径。

查看完整回答
反对 回复 2023-05-24
?
扬帆大鱼

TA贡献1799条经验 获得超9个赞

在你的 DemoController showHome 中应该返回一个 ModelAndView 这样的东西然后 ViewResolver 将它映射到home.jsp


@RequestMapping("/")

public ModelAndView showHome() {

    return new ModelAndView("home");

}

查看完整回答
反对 回复 2023-05-24
  • 2 回答
  • 0 关注
  • 83 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信