jsf - org.apache.el.parser.ParseException : Encountered "" }""} "" at line 1, 第 3 列

标签 jsf el

我有一个带有 jsf、xhtml 的 Web 项目。当我登录时,我将用户名和密码发送到 Prijava.java。

提交按钮<h:commandButton value="Potrdi" action="#{Prijava.prijava}" />

Prijava方法:

public String prijava() throws SQLException{
        Baza baza = new Baza();

            //Gets connection with database
        Connection conn = baza.povezi();

        java.sql.Statement stmt = conn.createStatement();

        ResultSet set = stmt.executeQuery("SELECT up_ime, geslo FROM uporabnik WHERE up_ime ='" +upIme +"'");

        while(set.next()){


            //String baza_up_ime = set.getString("up_ime");
            //String geslo = set.getString("geslo");
            //String uspesno = "";


        }

        return "Profil";

    }

该方法返回字符串“Profil”,因此页面应该重定向到我想要重定向用户的Profil.xhtml。 当我点击提交按钮时出现此错误:

org.apache.el.parser.ParseException: Encountered " "}" "} "" at line 1, column 3.
Was expecting one of:
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    "null" ...
    "(" ...
    "!" ...
    "not" ...
    "empty" ...
    "-" ...
    <IDENTIFIER> ...

我不知道那是什么以及如何解决它......之前,它有效:/

编辑:

Profil.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:x_rt="http://java.sun.com/jstl/xml_rt"
      xmlns:scriptfree="http://jakarta.apache.org/taglibs/standard/scriptfree"
      xmlns:permittedTaglibs="http://jakarta.apache.org/taglibs/standard/permittedTaglibs"
      xmlns:sql="http://java.sun.com/jsp/jstl/sql"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
      xmlns:x="http://java.sun.com/jsp/jstl/xml"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:fmt_rt="http://java.sun.com/jstl/fmt_rt"
      xmlns:c_rt="http://java.sun.com/jstl/core_rt">

<h:head></h:head> 


<head>
<title>: : Environmental Brand : :</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div id="dvmaincontainer">
  <!--main div container starts here-->
  <div id="dvtopcontainer">
    <!-- top container starts here-->
    <div id="dvlogocontainer">
      <!-- logo container starts here-->
      <h1>Najdi obrtnika</h1>
      <h4>Kjer koli in kadarkoli</h4>


      <!-- logo container ends here-->
    </div>
    <div id="dvnavicontainer">
      <!-- navogation div starts here-->
      <img src="images/navi_left.jpg" alt="" />
<div id="tabs1" >
        <ul>
          <!-- CSS Tabs -->
          <li ><a href="Index.xhtml"><span>Domača stran</span></a></li>
          <li id="current"><a href="Profil.xhtml"><span>Profil</span></a></li>
          <li><a href="Zahtevki.xhtml"><span>Zahtevki</span></a></li>
          <li><a href="Iskanje.xhtml"><span>Iskanje</span></a></li>
        </ul>
      </div>
      <img src="images/navi_right.jpg" alt="" />
      <!-- navogation div ends here-->
    </div>
    <!-- top container ends here-->
  </div>
  <div id="dvbodycontainer">




    <!-- body DIV1 starts here-->
    <div id="dvbannerbgcontainer">
      <!-- banner bg div starts here-->

      <p>Profil:</p>

        <f:view>
            Hello <h:outputText value="#{Prijava.upIme}"/>!
        </f:view>

      <table border="1px">
        <tr>
            <td>Ime:
            </td>
            <td>
            <h:inputText value="#{Uporabnik.ime}" />
            <!-- Za change text -->
            <!--  <h:commandButton value="Change text" actionListener="#{}" /> -->
            </td>
        </tr>
        <tr>
            <td>Priimek
            </td>
            <td>
            <h:inputText value="" />
            </td>
        </tr>

      </table>

      <!-- banner bg div ends here-->
    </div>






    <!-- body DIV2 starts here-->
    <div id="dvbannerbgcontainer">
      <!-- banner bg div starts here-->


      <!-- banner bg div ends here-->
    </div>





    <!-- body div ends here-->
  </div>
  <div id="dvfootercontainer">
    <!-- footer div starts here-->
    <div id="foottop">
     <p><span>Copyright  2013 Žiga Sternad, Gašper Sevčnikar, Jurij Valent, Primož Pavlin</span> </p>
      <div class="design"> <a href="#"><img src="images/studio.jpg" alt="Studio7designs" border="0" title="Studio7designs" /></a> </div>
    </div>
    <!-- footer div ends here-->
  </div>
  <!--main div container ends here-->
</div>
</body>

</html>

    enter code here

最佳答案

这是一个 EL 语法错误。它表示它在期望列出的标识符或关键字之一时遇到了 }

这很可能是由以下行引起的:

<!--  <h:commandButton value="Change text" actionListener="#{}" /> -->

#{} 确实是一个无效的 EL 表达式。

请注意,JSF/EL 在 Web 服务器上运行并生成 HTML 代码,并且它们对 HTML 注释不敏感(即它们是生成的 HTML 的一部分,而不是 JSF/EL 代码的一部分)。作为 HTML 代码解释器的网络浏览器是唯一对 HTML 注释敏感的。换句话说,HTML 注释不会阻止执行所包含的 JSF 标记和 EL 表达式,这与您的预期相反。

<小时/>

与具体问题无关,您的 JSTL 设置完全是一团糟。我看到了古老的 1.0 版本和原型(prototype)的 XML 命名空间声明。我强烈建议清理您在安装 JSTL 时不小心所做的一切,并在仔细阅读 our JSTL wiki page 后重新安装。 。您最终应该在 /WEB-INF/lib 中只有一个 JSTL 1.2 JAR 文件,并且 web.xml 中绝对没有松散的 TLD 文件或其他声明。

关于jsf - org.apache.el.parser.ParseException : Encountered "" }""} "" at line 1, 第 3 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17026849/

相关文章:

java - 表达式语言 : variables vs. 属性

jsp - <c :if test= > is always true

java - jsp需要写一段不同颜色的文字

java - Hibernate 一对多关系

java - 特殊领域的正则表达式重音字符

JSF getValue() 与获取提交的值()

java - EL 通过整数键访问映射值

java - 在没有 JSTL 的 EL 中打印简单字符串

jsf - 为什么只读属性不适用于 h :selectManyCheckbox?

java - 从标签或 jsp 调用 Java set 方法