我如何配置我的表达语言以使其在Eclipse中工作,同时还使用JSP / JSTL?只是JSP?

问题描述 投票:0回答:1

这是我的原始帖子。

https://stackoverflow.com/questions/62079182/is-not-working-on-my-jsp-page-how-can-i-get-my-html-tag-to-work-again?noredirect=1#comment109801916_62079182

我已经阅读了其中的内容,并尝试了多种方法。

我相信正在发生的事情是我的JSTL有自己的EL $ {}标签,而我的JSP有自己的EL $ {}标签。我觉得他们正在碰撞使内存空间为空或已清除。

问题:如何配置Eclipse以接受一个并禁用另一个?

如果我错了,请更正我,但不是当前使用Dynamic Web Project的4.0版本。这仅在Maven项目中有效吗?

jstl-1.2.jar是否使用严格版本的动态Web项目?这是问题吗?我应该使用Dynamic Web Project 3.0吗?甚至是2.5?我应该得到一个不同的jar文件吗?

[我再次是初级软件开发人员,试图了解为什么我的jar文件与动态Web项目中的JSP相比不能正常工作。请轻柔:D

这是向您显示从服务器运行时发生的情况。

This is when isELIgnored="true"

This is when isELIgnored="false"

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<c:forEach items="${students}" var="s" >
     ${s} <br/>
</c:forEach>



</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
                                                                                                                                                            <!--"http://xmlns.jcp.orb/xml/ns/javaee/web-app_2_5.xsd" version="2.5"-->
  <display-name>JSTLexample</display-name>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>


 <!--   *** This does nothing diffrent***
     <jsp-config>
         <jsp-property-group>
            <url-pattern>*.jsp</url-pattern>
            <el-ignored>false</el-ignored> 
        </jsp-property-group>
     </jsp-config>

--> 
</web-app>
package com.Demo;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/DemoServlet")
public class DemoServlet extends HttpServlet{

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {

        //String name = "Navin";

        List <Student> studs = Arrays.asList(new Student(1, "brandon"), new Student(2, "Micheal"), new Student (3, "Charles"));

        request.setAttribute("students", studs);

        RequestDispatcher rd = request.getRequestDispatcher("display.jsp");
        rd.forward(request, response);

    }
}
package com.Demo;

public class Student {
    int rollno;
    String name;


    @Override
    public String toString() {
        return "Student [rollno=" + rollno + ", name=" + name + "]";
    }


    public int getRollno() {
        return rollno;
    }


    public void setRollno(int rollno) {
        this.rollno = rollno;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    public Student(int rollno, String name) {
        super();
        this.rollno = rollno;
        this.name = name;
    }


}
java eclipse jsp jstl
1个回答
0
投票

所以问题的答案是我需要从servlet运行它,因为出于某些原因,我们不从JSP运行它。到目前为止,除非您更改HTML,否则请不要运行JSP。总是从servlet运行,因为它们彼此通信。

© www.soinside.com 2019 - 2024. All rights reserved.