标签: el

我遇到了尝试在JSTL标签中使用EL的问题

我正在尝试在jstl标签内使用表达式语言,但会发生奇怪的错误.

"根据标记文件中的TLD或属性指令,属性值不接受任何表达式"

代码是这样的:

<c:out value="${header['host']}"/>
Run Code Online (Sandbox Code Playgroud)

但下一个代码执行得很好:

${header["host"]}
<c:out value="hello"/>
Run Code Online (Sandbox Code Playgroud)

我将jstl.jar和standard.jar添加到WEB-INF/lib /(和classpath).包含jstl的指令是标准的:

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Run Code Online (Sandbox Code Playgroud)

JSTL版本是1.1.2

App-server:tomcat 6.0.16

jsp jstl el

1
推荐指数
1
解决办法
790
查看次数

如何在具有选定值的jsp/jstl中进行多选?

您好我有一个用户有一些角色User.class

public class User {

 private Long id;
 private String firstName;
 private String lastName;

 private Set<Role> roles = new HashSet<Role>(0);
Run Code Online (Sandbox Code Playgroud)

public Long getId(){return id; public void setId(Long id){this.id = id; }

 public String getFirstName() { return this.firstName; }
 public void setFirstName(String firstname) { this.firstName = firstname; }

 public String getLastName() { return this.lastName; }
 public void setLastName(String lastname) { this.lastName = lastname; }

 public Set<Role> getRoles() { return this.roles; }
 public void setRoles(Set<Role> roles) { this.roles = roles; }
} …
Run Code Online (Sandbox Code Playgroud)

java jsp jstl el

1
推荐指数
1
解决办法
8785
查看次数

JSTL c:选择问题

我需要使用JSTL select语句实现一个switch case,我有树不同的选择.任何人都知道下面的代码不起作用的原因?

提前致谢.

<c:choose>
    <c:when test="${iUserInfo.identification_card_type}==0">
        <option selected="selected">Carta di Identità</option>
        <option>Passaporto</option>
        <option>Patente di Guida</option>
    </c:when>
    <c:when test="${iUserInfo.identification_card_type}==1">
        <option>Carta di Identità</option>
        <option selected="selected">Passaporto</option>
        <option>Patente di Guida</option>
    </c:when>
    <c:when test="${iUserInfo.identification_card_type}==2">
        <option>Carta di Identità</option>
        <option>Passaporto</option>
        <option selected="selected">Patente di Guida</option>
    </c:when>
    <c:otherwise>
        <option>Scegli...</option>
        <option>Carta di Identità</option>
        <option>Passaporto</option>
        <option>Patente di Guida</option>
    </c:otherwise>
</c:choose>
Run Code Online (Sandbox Code Playgroud)

jsp jstl el

1
推荐指数
1
解决办法
5709
查看次数

表达式语言中的日历对象

如何以表达式语言获取日,月和年(以及每个Calendar.XXXXXXX值)?

${object.calendarObject.MONTH}
Run Code Online (Sandbox Code Playgroud)

java jsp el

1
推荐指数
1
解决办法
4437
查看次数

如何在不转义第二个表达式的情况下在两个EL表达式之间显示反斜杠\字面意思?

我有一个值属性:

value="#{mgdBean.directory}\\ #{mgdBean.file}"
Run Code Online (Sandbox Code Playgroud)

我需要修剪目录和文件名之间的空白区域,以使值显示为:

目录\文件.

我无法移除空格,因为逃逸序列\会逃脱第二个EL表达式.

el jsf-2

1
推荐指数
1
解决办法
1365
查看次数

无法通过EL传递参数到方法 - javax.el.MethodNotFoundException

使用JSF 2.0和EL,我试图在POJO上调用一个方法,POJO是一个viewscoped bean的属性.该代码实际上是非常相似的@BalusC的教程在这里.当我调用一个不带参数的方法时,一切都很好.但是当我尝试调用一个带参数的方法时,我得到以下异常:

javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException:
/user.xhtml at line 42 and column 32 action="#{users.user.removeFriend(friend)}":
Method not found: model.User@67f2b0dd.removeFriend()
Run Code Online (Sandbox Code Playgroud)

以下是一些更多细节:

user.xhtml

<f:metadata>
    <f:viewParam name="id" value="#{users.id}" />
    <f:event type="preRenderView" listener="#{users.init}" />
</f:metadata>

...

<h:form id="usersForm">
    <p:outputPanel>    
        <p:dataTable id="userTable" value="#{users.user.friendList}" var="friend">
            <p:column>
                <h:outputText value="#{friend.name}" />
            </p:column>
            <p:column>
                <p:commandButton action="#{users.user.removeFriend(friend)}"
                    ajax="true"
                    update="userTable somethingElse" process="@this"
                    onerror="errorDialog.show();"
                    icon="ui-icon-delete"
                    title="delete user">
                </p:commandButton>
            </p:column>
        </p:dataTable>
    </p:outputPanel>

    <p:commandButton action="#{users.user.removeAllFriends()}" ajax="true"
                update="userTable somethingElse"
                process="@this"
                icon="ui-icon-close"
                value="delete all friends?">
    </p:commandButton>


</h:form>
Run Code Online (Sandbox Code Playgroud)

我有以下ViewScopedbean:

Users.java

@ManagedBean(name = "users") …
Run Code Online (Sandbox Code Playgroud)

java jsf tomcat el primefaces

1
推荐指数
1
解决办法
1万
查看次数

JSP EL中未找到属性异常

很烦人.不知道为什么会出现这个错误.在下面的代码中

NOTE:

if I only use <td>${user.id}</td> than its printing id properly but on ${user.username} property generating error. See below JSP page code.

If I use below code in JSP page like to test than I get all the objects and properties


<c:forEach var="user" items="${users}" varStatus="i">
    <tr>
        <td>${users[i.index]}</td>
    </tr>                       
</c:forEach>

Result:

User[id=1,username=u1,password=p1,firstname=f1,lastname=l1,dob=2012-07-01,age=40]
User[id=2,username=u2,password=p2,firstname=f2,lastname=l2,dob=2012-07-02,age=39]
User[id=3,username=u3,password=p3,firstname=f3,lastname=l3,dob=2012-07-03,age=38]
Run Code Online (Sandbox Code Playgroud)

错误:

09:49:49,047 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/crud_jsp_servlet_cdi_jdbc_tagfile].[jsp]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet jsp threw exception: javax.el.PropertyNotFoundException: The class 'com.myapp.dao.User' does not have the property 'username'.
    at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661) [jboss-el-api_2.2_spec-1.0.0.Final.jar:1.0.0.Final]
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:290) …
Run Code Online (Sandbox Code Playgroud)

jsp servlets el java-ee

1
推荐指数
1
解决办法
2152
查看次数

通过EL显示多行文本

我在显示多行文本时遇到问题.例如,用户可以textarea在注册表单中键入其文本,并且文本可以是多行,即他可以按Enter(返回)键来插入换行符.

在一个页面上,如果我想显示他键入的文本并使用textarea显示(with EL),它会显示用户最初输入的方式.

但在另一页上,我需要以段落格式(使用<p>标签)显示此文本.在此页面上,当我显示用户在注册时输入的值时,它没有换行符,即它显示在一行而不是用户输入的多行.

我已经尝试EL<p>标记内显示文本,并在标记中使用<c:out>JSTL的<p>标记.

我尝试过的一些代码:
Trial-1:

<p>${product.description}</p> //Doesn't show line breaks
Run Code Online (Sandbox Code Playgroud)

试验2:

<p><c:out value="${product.description}" /></p> //Doesn't show line breaks too
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

html jsp jstl el

1
推荐指数
1
解决办法
1042
查看次数

JSP页面中的PropertyNotFoundException

我有一个Java bean类如下

public class Users extends dbConnect
{
   private int UserId;  

   public int getUserId() 
   {
    return UserId;
   }

   public void setUserId(int userId) 
   {
     UserId = userId;
   }
}
Run Code Online (Sandbox Code Playgroud)

我在我的Servlet中有一个doGet方法,它获取javabean类中的值并在JSP页面中显示.ListUsers方法将从数据库返回一个列表.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        List<Users> arrUserList = new ArrayList<Users>();

        Users objUser = new Users();
        arrUserList   = objUser.listUsers();

        for(Users Userobj : arrUserList)
        {
            System.out.println(Userobj.getUserId());
        }

        request.setAttribute("arrUserDetails", arrUserList);

        RequestDispatcher rst = request.getRequestDispatcher("ListUsers.jsp");
        rst.forward(request, response);
    }
Run Code Online (Sandbox Code Playgroud)

当我在for循环上面打印UserId的值时,显示UserId.But它没有显示在我的JSP页面中.

<%@ page  import="com.acme.users.Users"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:forEach items="${arrUserDetails}" var="account">
<tr> …
Run Code Online (Sandbox Code Playgroud)

jsp el propertynotfoundexception

1
推荐指数
1
解决办法
2万
查看次数

如何使用jstl和EL迭代JSP中的对象列表?

我将一个List从我的Spring MVC控制器类传递到我的jsp页面.此列表包含多个对象,即.,List.我需要迭代这些对象来获取值.如何使用jstl和EL迭代值(不使用简单的for循环).我在jsp文件中的代码是......

  <c:forEach items="${myList}" var="allEmp"> //'myList' is the list that I passing from my controller class. ie., List<Employee>
     //after iterating list, it will return Employee object.From this employee object, I want to iterate the values
      <tr>
         <td><c:out value="${allEmp.employee.getEmpId()}"/></td>
         <td><c:out value="${allEmp.employee.getFirstName()}"/></td>
         <td><c:out value="${allEmp.employee.getLastName()}"/></td>
      </tr>
    </c:forEach>
Run Code Online (Sandbox Code Playgroud)

我知道我的代码是错的.如何从Employee对象进行迭代.我是否需要为每个循环迭代员工对象?请帮帮我.

java jsp jstl el spring-mvc

1
推荐指数
1
解决办法
2723
查看次数