【发布时间】:2014-03-12 04:34:03
【问题描述】:
调用 jsp 页面时不呈现 EL 标记。
<c:out value="${uploadedImage.value.getDocumentName()}"/>
打印 ${uploadedImage.value.getDocumentName()}
我的 pom 文件是
<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">
<url>http://maven.apache.org</url>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.4.Final</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>7.0.12</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-el-api</artifactId>
<version>7.0.12</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<version>7.0.12</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<finalName>ImageManagement</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
我的 web.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>
</web-app>
Web 应用程序具有所有 Servlet 映射。
我的项目配置是 雄猫 7.0 Eclipse 开普勒
<c:if test = "${not empty uploadedImages}">
<% int i = 0; %>
<c:forEach var="uploadedImage" items="${uploadedImages}">
<tr>
<% i++; %>
<td><%= i %></td>
<td><c:out value="${uploadedImage.value.getDocumentName()}"/></td>
<td><c:out value="${uploadedImage.value.getDocumentSize()}"/></td>
<!-- <td><img src="image?id=${uploadedImage.value.getUserRepositryId()}" style = "height : 80px; width : 50px" alt = "image here"/></td>-->
<td>
<a href = "delete?id=${uploadedImage.value.getUserRepositryId()}"> Delete </a>
<a href = "edit?id=${uploadedImage.value.getUserRepositryId()}"> Edit </a>
</td>
</tr>
</c:forEach>
</c:if>
uploadedImages 是一个 HashMap 变量,它被设置为 Session 对象。 它从数据库中获取保存的图像并将其保存为 HashMap。 数据库部分工作正常,它从数据库加载图像并将它们保存在 HashMap 中。
唯一的问题是工作中的 EL 标签。 这个项目在没有 maven 的情况下运行良好。
UserRepositryDTO.java
public class UserRepositryDTO {
private int userRepositryId;
private int userId;
private String documentName;
private long documentSize;
private byte[] document;
private String message;
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message the message to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the userRepositryId
*/
public int getUserRepositryId() {
return userRepositryId;
}
/**
* @return the userId
*/
public int getUserId() {
return userId;
}
/**
* @return the documentName
*/
public String getDocumentName() {
return documentName;
}
/**
* @return the documentSize
*/
public long getDocumentSize() {
return documentSize;
}
/**
* @return the document
*/
public byte[] getDocument() {
return document;
}
/**
* @param userRepositryId the userRepositryId to set
*/
public void setUserRepositryId(int userRepositryId) {
this.userRepositryId = userRepositryId;
}
/**
* @param userId the userId to set
*/
public void setUserId(int userId) {
this.userId = userId;
}
/**
* @param documentName the documentName to set
*/
public void setDocumentName(String documentName) {
this.documentName = documentName;
}
/**
* @param documentSize the documentSize to set
*/
public void setDocumentSize(long documentSize) {
this.documentSize = documentSize;
}
/**
* @param document the document to set
*/
public void setDocument(byte[] document) {
this.document = document;
}
}
UserDTO.java
public class UserDTO {
private int userId;
private String username;
private String message;
private long totalSize;
private Map<Integer,UserRepositryDTO> userRepositry;
/**
* @return the totalSize
*/
public long getTotalSize() {
return totalSize;
}
/**
* @param totalSize the totalSize to set
*/
public void setTotalSize(long totalSize) {
this.totalSize = totalSize;
}
/**
* @return the userId
*/
public int getUserId() {
return userId;
}
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param userId the userId to set
*/
public void setUserId(final int userId) {
this.userId = userId;
}
/**
* @param username the username to set
*/
public void setUsername(final String username) {
this.username = username;
}
/**
* @param message the message to set
*/
public void setMessage(final String message) {
this.message = message;
}
public Map<Integer,UserRepositryDTO> getUserRepositry() {
return userRepositry;
}
public void setUserRepositry(Map<Integer,UserRepositryDTO> userRepositry) {
this.userRepositry = userRepositry;
}
}
这个问题是由于servlet jsp jstl的不同版本造成的。我不知道正确的版本。
【问题讨论】:
-
你使用EL无效..试试
${uploadedImage.value.documentName} -
这是有效的,因为 getDocumentName 是返回文档名称的函数 -
请添加你有
getDocumentName()的类。您在 OP 中添加的依赖项很有用..
标签: eclipse jsp maven tomcat jstl