简体   繁体   中英

Jboss: EL expression in JSP doesn't work

I am running Jboss EAP 6.3. I have this form:

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>registrationPage.jsp</title>
</head>
<body>
<h1>Welcome to JBoss!</h1>

<div>
    <p>You have successfully deployed a Java EE 6 web
        application.</p>
</div>

<form id="reg" action="register.do" method="POST">
    <h2>Member Registration</h2>
    <table>
        <tr>
            <td style="text-align: right;"><label for="name">Name:</label>
            </td>
            <td><input type="text" id=name name="name"
                       value="${newMember.name}" /></td>
        </tr>
        <tr>
            <td style="text-align: right;"><label for="email">Email:</label>
            </td>

            <td><input type="text" id="email" name="email"
                       value="${newMember.email}" /> <!-- <h:message  for="email" errorClass="invalid" />-->
            </td>
        </tr>
        <tr>
            <td style="text-align: right;"><label
                    for="phoneNumber">Phone #:</label></td>
            <td><input id="phoneNumber" name="phoneNumber"
                       type="text" value="${newMember.phoneNumber}" /></td>
        </tr>
    </table>
    <p>
        <input id="register" type="submit" value="Register" />
    </p>
    <p>
        <label style="color: green;width: 100%;text-align: left;">${infoMessage}</label>
    </p>
    <p>
        <label style="color: red; width: 100%;text-align: left;">${errorMessage}</label>
    </p>
</form>




</body>
</html>

I am pretty sure I didn't change anything since yesterday, but today I woke up and it now looks like this:

在此处输入图片说明

There are no errors as far as I can see.

It has been solved by adding

isELIgnored="false" 

to the page. Like this:

<%@ page language="java" contentType="text/html; charset=UTF-8"   isELIgnored="false"  pageEncoding="ISO-8859-1"%>

Apparently EL expressions are ignored by default and you have to manually enable them.

At first check that you have filled up the object "newMember" appropriately before loading this page. Then you can use the following process to show data in your view:

  1. At first use this line top of your view page:

    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

  2. Then use the following process for your table, showing on the view. Here I have only shown the changes:

     <td><input type="text" id=name name="name" value='<c:out value="${newMember.name}"></c:out>'/> </td> <td><input type="text" id="email" name="email" value='<c:out value="${newMember.email}"></c:out>'/> </td> <td><input id="phoneNumber" name="phoneNumber" type="text" value='<c:out value="${newMember.phoneNumber}"></c:out>'/> 

3.I think it's a better process to show data in a view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM