EL没有显示任何输出

时间:2017-01-07 17:22:08

标签: jsp el

所以,我只是学习JSP和Java-EE。我做了这个测试程序,但EL没有显示任何输出。

这是我的JSP代码:



<%@page contentType="text/html" pageEncoding="UTF-8" import="com.test.TestServlet" isELIgnored="false"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Test JSP</h1>
        ${person.name}'s dog ${person.dog.name}'s toys are: ${person.dog.toys[0].name}, ${person.dog.toys[1].name} and ${person.dog.toys[2].name}
    </body>
</html>
&#13;
&#13;
&#13;

Servlet代码:

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    Person p = new Person();
        p.setName("Leelu");
        Dog d = new Dog();
        d.setName("Clyde");
        Toy t1 = new Toy();
        t1.setName("Stick");
        Toy t2 = new Toy();
        t2.setName("neighbour's cat");
        Toy t3 = new Toy();
        t3.setName("Barbie doll head");

        d.setToys(new Toy[]{t1,t2,t3});
        p.setDog(d);
        request.setAttribute("person", p);


        RequestDispatcher view = request.getRequestDispatcher("/WEB-INF/testJSP.jsp");
        view.forward(request, response);
}

web.xml代码:

&#13;
&#13;
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <servlet>
        <servlet-name>TestServlet</servlet-name>
        <servlet-class>com.test.TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/TestServlet</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>
&#13;
&#13;
&#13;

我正在使用带有Glassfish 4.1.1的Netbeans 8.2 IDE。我在这里做错了什么?

编辑:添加了web.xml代码。

0 个答案:

没有答案