0

以下で奇妙な動作が発生しています。Spring Controller にモデル オブジェクトを追加しています。jsp で jstl を使用して同じオブジェクトにアクセスすると、そこには何も表示されません。

私のプロジェクトは、Java 1.8+ Tomcat 8.0+ Maven に基づいて構築された REST ベースです。

私のMavenプロジェクトは、モジュールreporting-restおよびreporting-daoを持つreportingという名前です。Jsp ページとコントローラーは、reporting-rest にあります。

ポン。Reporting-rest の xml コンテンツ

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.reporting</groupId>
        <artifactId>reporting</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>reporting-rest</artifactId>
    <packaging>war</packaging>
    <properties>
        <servlet.version>2.5</servlet.version>
         <spring.version>3.2.4.RELEASE</spring.version>
        <log4j.version>1.2.17</log4j.version>
         <jdk.version>1.7</jdk.version>
        <context.path>SpringRestSecurityOauth</context.path>
        <spring.security.version>3.2.5.RELEASE</spring.security.version>
    </properties>
    <name>reporting-rest Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>

    <!--    <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency> -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <!-- log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <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>

        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
            <version>1.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.10</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
        <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.reporting.dao</groupId>
            <artifactId>reporting-dao</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>reporting-rest</finalName>
                <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <wtpversion>2.0</wtpversion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>
             </plugins>
    </build>

</project>

レポートの pom.xml コンテンツ (親)

<?xml version="1.0" encoding="UTF-8"?>
<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>org.reporting</groupId>
    <artifactId>reporting</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <properties>
         <org.springframework.version>3.2.4.RELEASE</org.springframework.version> 
        <org.slf4j-version>1.7.5</org.slf4j-version>
        <org.json.version>20080701</org.json.version>
        <jackson-mapper.version>1.9.12</jackson-mapper.version>
        <jsp.version>2.2</jsp.version>

        <junit.version>4.11</junit.version>
        <org.postgresql.version>9.0-801.jdbc4</org.postgresql.version>
        <commons-dbcp.version>1.4</commons-dbcp.version>
        <cglib.version>2.2.2</cglib.version>
        <servlet.version>2.5</servlet.version>
        <spring-security.version>3.1.4.RELEASE</spring-security.version>
        <org.aspectj.version>1.6.12</org.aspectj.version>
        <spring-aop.version>3.2.5.RELEASE</spring-aop.version>
        <org.testng.version>6.8.7</org.testng.version>
        <spring-test.version>3.2.5.RELEASE</spring-test.version>
        <org.aspectj.version>1.6.2</org.aspectj.version>
        <env>dev</env>
        <project.parent.basedir>../</project.parent.basedir>
    </properties>
    <modules>
        <module>reporting-rest</module>
        <module>reporting-dao</module>
    </modules>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
    </dependencies>
</project>

ウェブ。xml ファイル

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:config/*-context.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>reporting</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>reporting</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
<!--    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> -->

    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
</web-app>

Reporting-rest 用のサーブレット xml ファイル

<?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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:task="http://www.springframework.org/schema/task" xmlns:oxm="http://www.springframework.org/schema/oxm"
    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/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
                http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
                http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
                http://www.springframework.org/schema/security
                http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <context:component-scan base-package="org.reporting.rest" />
    <!-- <context:annotation-config/> -->
    <mvc:annotation-driven />
     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
      <property name="prefix" value="/WEB-INF/jsp/" />
      <property name="suffix" value=".jsp" />
   </bean>

    </beans>

Reporting-rest のコントローラ クラス

@Controller
@RequestMapping("/api/admin/")
public class AdminController {
    @RequestMapping(value = "/clients", method = RequestMethod.GET)
    public ModelAndView listClients() {
        ModelAndView model = new ModelAndView("clientDetails");
        //List<Client> clients=adminDAO.getClients();
        List<String> lists = new ArrayList<String>();
        lists.add("List A");
        lists.add("List B");
        lists.add("List C");
        lists.add("List D");
        lists.add("List 1");
        lists.add("List 2");
        lists.add("List 3");;
        model.addObject("lists",lists );
        model.addObject("matter","This is another matter" );
        return model;
    }
}

Reporting-rest にある jsp ビュー

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
    <h2>List Clients</h2>
    ${lists}

    Matter:: ${matter}
    <c:if test="${not empty lists}">

        <ul>
            <c:forEach var="listValue" items="${lists}">
                <li>${listValue}</li>
            </c:forEach>
        </ul>

    </c:if>
</body>
</html>

上記の JSP を出力します。

List Clients
${lists} Matter:: ${matter} 

コンテンツは出力されず、${} でそのまま取得されます

これについて親切に助けてください。

4

1 に答える 1