spring构建web应用以及ModelAndView中的 model value 在JSP中的EL表达式显示null解决办法

本文介绍了一个Spring构建的Hello World Web应用,使用Java配置而非XML。在遇到ModelAndView中的model value在JSP中显示为null的问题时,提供了两种解决方案:1) 使用JSP 1.2 descriptor;2) 使用JSP 2.0标准descriptor。
摘要由CSDN通过智能技术生成

创建一个Hello world的例子,使用Java配置。 通过对应的Java替换XML配置。

以 Spring Java为基础的配置取决于Servlet 3.0 的API, 因此,我们需要包含的依赖在 pom.xml 中。

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.dhb.demo</groupId>
  <artifactId>spring4MVCHelloWorldNoXMLDemo</artifactId>
  <packaging>war</packaging>
  <version>0.1.0-SNAPSHOT</version>
  <name>spring4MVCHelloWorldNoXMLDemo Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <properties>
    <jetty.context>/</jetty.context>
    <jetty.http.port>9089</jetty.http.port>
    <jetty.https.port>9444</jetty.https.port>
    <jetty.stopPort>10081</jetty.stopPort>

    <spring.version>4.1.4.RELEASE</spring.version>
  </properties>

  <dependencies>
    <!-- spring -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-expression</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>



    <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>


  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <showWarnings>true</showWarnings>
        </configuration>
      </plugin>

      <!--maven jetty 插件配置-->
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
       
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值