Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse EL-tag在tomcat 7中不与maven一起工作_Eclipse_Jsp_Maven_Tomcat_Jstl - Fatal编程技术网

Eclipse EL-tag在tomcat 7中不与maven一起工作

Eclipse EL-tag在tomcat 7中不与maven一起工作,eclipse,jsp,maven,tomcat,jstl,Eclipse,Jsp,Maven,Tomcat,Jstl,调用jsp页面时不呈现EL标记。 打印${UploadeImage.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

调用jsp页面时不呈现EL标记。

打印${UploadeImage.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>
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;
}
}
公共类UserDTO{
私有int用户id;
私有字符串用户名;
私有字符串消息;
私人长期总规模;
私有地图用户存储;
/**
*@返回总大小
*/
公共长getTotalize(){
返回总大小;
}
/**
*@param totalSize要设置的totalSize
*/
公共void setTotalSize(长totalSize){
this.totalSize=totalSize;
}
/**
*@返回用户ID
*/
public int getUserId(){
返回用户标识;
}
/**
*@返回用户名
*/
公共字符串getUsername(){
返回用户名;
}
/**
*@回信
*/
公共字符串getMessage(){
返回消息;
}
/**
*@param userId要设置的用户标识
*/
public void setUserId(最终int userId){
this.userId=userId;
}
/**
*@param username要设置的用户名
*/
public void setUsername(最终字符串用户名){
this.username=用户名;
}
/**
*@param message要设置的消息
*/
公共无效设置消息(最终字符串消息){
this.message=消息;
}
公共映射getUserRepositry(){
返回用户存储;
}
public void setUserRepository(映射userRepository){
this.userRepositry=userRepositry;
}
}

问题是由于servlet jsp jstl的不同版本造成的。我不知道正确的版本。

首先,不要使用
Scriptlets()
获取循环的索引,您可以从
获取索引,您需要修复web.xml。它声明它使用Servlet2.3,这相当于不支持EL的JSP1.2

尝试使用以下类似的方法:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0"
         metadata-complete="true">
</web-app>


您使用的EL无效。。请尝试
${uploadeImage.value.documentName}
这是有效的,因为getDocumentName是返回文档名称的函数。请在
getDocumentName()中添加类。您在OP中添加的依赖项是有用的。。
<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>
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;
}
}
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;
}
}
req.setAttribute("uploadedImages", uploadedImages);
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:choose>
  <c:when test="${not empty uploadedImages}">
    <c:forEach var="uploadedImage" items="${uploadedImages}" varStatus="status">
        <tr>
            <!--Her, don't use Scriptlets to get index, get index from <c:forEach varStatus -->
            <td>${status.index}</td> 
            <td><c:out value="${uploadedImage.value.documentName}"/></td>
            <td><c:out value="${uploadedImage.value.documentSize}"/></td>
            <!-- <td><img src="image?id=${uploadedImage.value.userRepositryId}" style = "height : 80px; width : 50px" alt = "image here"/></td>-->

            <td>
                <a href = "delete?id=${uploadedImage.value.userRepositryId}"> Delete </a>
                <a href = "edit?id=${uploadedImage.value.userRepositryId}"> Edit </a>
            </td>
        </tr>
    </c:forEach>
</c:when>
<c:otherwise>
   uploadedImages Map is empty..
</c:otherwise>
<c:choose>
${uploadedImage.value.documentName} <!--internally EL will invoke getDocumentName() to get documentName value-->
<c:out value="${uploadedImage.value.documentName}"/>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0"
         metadata-complete="true">
</web-app>