标签: el

无法访问包含的JSP内的变量

我在我的应用程序中使用Spring 2.5.在视图中我有主jsp,其中我包含了另一个jsp.我在主jsp中使用c:set标签声明了一个变量,我无法在jsp中访问它.下面是代码main.jsp

<c:set var="hPediquestStudy"><spring:message code="study.hpediquest.mapping" /></c:set>
<c:set var="currentStudy" value='<%=(String)session.getAttribute("currentStudy")%>'/>
<html>
<head>
</head>
<body>
<c:if test="${currentStudy eq hPediquestStudy}">
  Variables are equal
</c:if>
<c:if test="${currentStudy ne hPediquestStudy}">
  Variables are not equal
</c:if>
<jsp:include page="/WEB-INF/jsp/included.jsp"></jsp:include>
</body
</html>
Run Code Online (Sandbox Code Playgroud)

included.jsp

<c:if test="${currentStudy eq hPediquestStudy}">
   hPediquestStudy Variable is accessible
</c:if>
 <br/>currentStudy : ${currentStudy}
 <br/>hPediquestStudy : ${hPediquestStudy}
Run Code Online (Sandbox Code Playgroud)

我正在输出

变量是平等的

currentStudy:hPediquest

hPediquestStudy:

  1. 为什么在主jsp上两个值都相等而在包含jsp中我看不到它的值?
  2. 为什么currentStudy在包含的jsp中显示其值?
  3. 是否有任何解决方案可以帮助我访问父jsp中的变量集ans可以在包含的jsps中访问?

如果我在主jsp中包含jsp中设置该变量,我可以看到hPediquestStudy值的值.但是每次我加入jsp时我都不想设置它.请帮忙

spring jsp jstl el

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

在EL中连接字符串

以下一直保持返回null知道原因

<ui:param name="dialogName" value="#{index.toString().concat('Overlay')}" />
Run Code Online (Sandbox Code Playgroud)

jsf el

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

JSF bean属性未在外部JavaScript文件中评估

如果我想从JavaScript中评估一个JSF bean属性,我发现如果JavaScript代码片段在xhtml文件中,它可以工作,但是当JavaScript代码片段在一个单独的js文件中时,它不起作用.

所以,这有效:

的index.xhtml

...
<h:body>
    <script type="text/javascript" src="resources/Javascript/jquery/jquery-1.7.2.js" />
    <script type="text/javascript" >
        $(document).ready(function() {
            alert('#{myBean.myProperty}');
        });
    </script>        
</h:body>
Run Code Online (Sandbox Code Playgroud)

但这不会评估ManagedBean的属性:

的index.xhtml

...
<h:body>
    <script type="text/javascript" src="resources/Javascript/jquery/jquery-1.7.2.js" />
    <script type="text/javascript" src="resources/Javascript/MyJS.js" />
</h:body>
Run Code Online (Sandbox Code Playgroud)

MyJS.js

$(document).ready(function() {
    alert('#{myBean.myProperty}');
});
Run Code Online (Sandbox Code Playgroud)

在第二种情况下,警告框包含未评估的字符串 #{myBean.myProperty}

如何从外部js文件中使其工作?

javascript jsf el java-ee

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

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

JSF Epic EL警告,我应该担心吗?

我正在开发与JSF 2和PrimeFaces(3.5)一起使用的Liferay产品。我正在使用Eclipse,并且当我在Project Facets中启用了“ Java Server Faces”时,出现了这个惊人的错误

    Multiple annotations found at this line:
- Syntax error in EL
- Method must have signature "String method(), String method(String), String method(String, String), String method(String, String, String), String method(String, String, 
 String, String), String method(String, String, String, String, String), String method(String, String, String, String, String, String), String method(String, String, String, String, String, String, 
 String), String method(String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String), String method(String, …
Run Code Online (Sandbox Code Playgroud)

java eclipse jsf el primefaces

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

org.apache.jasper.JasperException:模板文本中不允许#{...}

我试图在JSP和Spring MVC的浏览器屏幕上显示一条简单的消息.

<h2>#{message}</h2>
Run Code Online (Sandbox Code Playgroud)

但是,它抛出了以下异常:

org.apache.jasper.JasperException: /Ekle/DomainEkle.jsp (line: 9, column: 6) #{...} is not allowed in template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:103)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:733)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:954)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1798)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
Run Code Online (Sandbox Code Playgroud)

这是怎么造成的,我该如何解决?

jsp el spring-mvc

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

无法使用JBoss EAP 6.2找到EL RI表达式工厂

我'使用Jboss EAP 6.1,Eclipse Kepler,Maven(嵌入在Eclipse版本).然后应用程序启动,我有这个错误:

            It appears the JSP version of the container 
        is older than 2.1 and unable to locate the EL RI expression factory, 
com.sun.el.ExpressionFactoryImpl.  If not using JSP or the EL 
    RI, make sure the context initialization parameter, 
    com.sun.faces.expressionFactory, is properly set.
Run Code Online (Sandbox Code Playgroud)

这是pom.xml:

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>it.imageorder</groupId>
        <artifactId>imageorder</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <groupId>it.imageorderwebmodule</groupId>
    <artifactId>ImageOrderWebModule</artifactId>
    <version>0.0.2-SNAPSHOT</version>
    <packaging>ear</packaging>
    <name>ImageOrderWebModule Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>


        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId> …
Run Code Online (Sandbox Code Playgroud)

jboss el java-ee maven jsf-2

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

如何在表达式语言中拆分字符串并获取最后一个元素?

这是我正在尝试但似乎不起作用:

(myStringHere.split(".")[(myStringHere.split(".").length)-1]).concat(text[myStringHere])
Run Code Online (Sandbox Code Playgroud)

我的字符串将是这样的:

com.foo.bar.zar.gar.ThePartIWant
Run Code Online (Sandbox Code Playgroud)

ThePartIWant是我想在页面中显示的内容.

我正在使用Expression Language 2.2

java string jsp split el

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

EL#{bean.id}如何调用托管bean方法bean.getId()

我真的不理解吸气剂和塞特剂的工作原理,尽管这是一个基本概念。我有以下代码,该属性如何id发送到Managed Bean?用getter方法捕获了吗?

我的面

<p:inputText id="id" value="#{bean.id}">
Run Code Online (Sandbox Code Playgroud)

我的托管豆

private String id;

public void setId(String id) {
    this.id = id;
}

public String getId() {
      return id;
}
Run Code Online (Sandbox Code Playgroud)

getter jsf el

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

#{resource} EL指定在哪里?

在JSF页面中,我使用EL来查找放在/resource/images/文件夹中的图像.

<h:graphicImage value="#{resource['images:logo.gif']}"
Run Code Online (Sandbox Code Playgroud)

EL如何定位图像?也许规范定义了规则,但我不知道哪个规范.我尝试在JSR-000344 JavaServer Faces 2.2,JSR-000342 Java平台,企业版7,JSR-000341表达式语言3.0中找到它,但没找到.

resources jsf specifications el

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