相关疑难解决方法(0)

如何安装JSTL?绝对的uri:http://java.sun.com/jstl/core无法解决

我不知道我做错了什么,但我不能包括JSTL.我有jstl-1.2.jar,但不幸的是我得到了例外:

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:429)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1439)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:137)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
    at org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) …
Run Code Online (Sandbox Code Playgroud)

jsp servlets jstl

124
推荐指数
8
解决办法
34万
查看次数

有条件地显示JSF组件

首先,我是Java EE的新手,来自强大的ASP .NET开发背景.我已经浏览了网络,我可能会错过这个,但似乎没有关于如何将支持bean类连接到JSF组件的简单直接的教程.

一个很好的例子是这样的,目前我正在尝试创建一个JSF页面,其中有一组链接作为菜单栏和一组表单.我打算做的是,当点击一个链接时,将呈现一个特定的表单.

在ASP.NET中,我可以轻松检索元素,然后将属性设置为可显示.我想知道在JSF中是否有简单的方法(哎呀,甚至任何方式).

表单已经在页面中,只需在单击特定链接时将"render"属性设置为true即可.

jsf components conditional-rendering

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

"绑定"属性如何在JSF中起作用?应该何时以及如何使用?

在JSF中有很多材料区分value属性和binding属性.

我对这两种方法如何彼此不同感兴趣.鉴于:

public class User {
    private String name;
    private UICommand link;

    // Getters and setters omitted.
}
Run Code Online (Sandbox Code Playgroud)
<h:form>
    <h:commandLink binding="#{user.link}" value="#{user.name}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

value指定属性时会发生什么变化.getter运行以返回bean 的name属性值User.该值将打印到HTML输出.

但我无法理解它是如何binding运作的.生成的HTML如何维护与bean link属性的绑定User

下面是手动美化和注释后生成的输出的相关部分(注意id j_id_jsp_1847466274_1是自动生成的,并且有两个隐藏的输入小部件).我正在使用Sun的JSF RI 1.2版.

<form action="/TestJSF/main.jsf" enctype="application/x-www-form-urlencoded"
    id="j_id_jsp_1847466274_1" method="post"  name="j_id_jsp_1847466274_1">
    <input name="j_id_jsp_1847466274_1" type="hidden" value="j_id_jsp_1847466274_1">
    <a href="#" onclick="...">Name</a>
    <input autocomplete="off" id="javax.faces.ViewState" name="javax.faces.ViewState"
        type="hidden" value="-908991273579182886:-7278326187282654551">
</form>
Run Code Online (Sandbox Code Playgroud)

在哪里binding存放在这里?

jsf binding components jsf-2

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

在JSF页面中定义和重用EL变量

是否可以在EL表达式中定义变量并重新使用该变量?

例如 :

<h:inputText 
   value="#{myBean.data.something.very.long}"
   rendered="#{myBean.data.something.very.long.showing}"
/>
Run Code Online (Sandbox Code Playgroud)

我的想法是这样的:

<!-- 
     somehow define a variable here like : 
     myVar = #{myBean.data.something.very.long} 
-->
<h:inputText 
   value="#{myVar}"
   rendered="#{myVar.showing}"
/>
Run Code Online (Sandbox Code Playgroud)

有任何想法吗 ?谢谢 !

jsf el jsf-2

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

如何有条件地渲染f:selectItem标签?

如何为<f:selectItem>标记指定条件呈现.我需要<f:selectItem>根据特定用户的状态显示选项.

例如,我想要的东西如下:

<f:selectItem itemLabel="Yes! I need a girlfriend!"
             rendered="false(or some boolean condition)"
             itemValue="o1"/>
Run Code Online (Sandbox Code Playgroud)

jsf rendered-attribute

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

如何通过导航菜单ajax-refresh动态包含内容?(JSF SPA)

我正在学习JSF 2,感谢我在这么短的时间里学到了很多东西.

我的问题是关于如何为我的所有JSF 2页面实现一个公共布局,并且每当我从另一个面板单击一个链接/菜单时,只有页面的内容部分不刷新整个页面.我使用Facelets方法它做了我想做的事情,除了每次我点击一个面板的链接(例如左面板的菜单项)时,整个页面都会刷新.我正在寻找的是一种只刷新页面内容部分的方法.为了说明这一点,我的目标是pagelayout.

在此输入图像描述 没有发布我的代码,因为我不确定Facelets是否可以这样做.除了Facelets之外,还有其他方法更适合我的要求吗?

jsf facelets uiinclude single-page-application ajax-update

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

为什么Facelets比JSF2.0以后的视图定义语言更优先于JSP?

我从JSF2.0开始看到,Facelets视图定义语言是首选的视图定义语言,而不是作为遗留后退而被弃用的JSP.我想理解为什么Facelets比JSF2.0以后的视图定义语言更优先于JSP?我知道JSP也有一些模板行为,这是采用Facelets的主要驱动点.

PS:我在stackoverflow上经历过这篇文章,但我不认为它回答了我的问题.因此将此作为单独的问题发布.

jsf jsp facelets jsf-2

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

为什么@PostConstruct回调每次都会触发,即使bean是@ViewScoped?JSF

我在页面上使用datatable并使用绑定属性将其绑定到我的支持bean.这是我的代码: -

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
            <h:form prependId="false">

                <h:dataTable var="item" value="#{testBean.stringCollection}" binding="#{testBean.dataTable}">
                    <h:column>
                        <h:outputText value="#{item}"/>
                    </h:column>
                    <h:column>
                        <h:commandButton value="Click" actionListener="#{testBean.action}"/>
                    </h:column>
                </h:dataTable>

            </h:form>

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

这是我的豆子: -

package managedBeans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.component.html.HtmlDataTable;

@ManagedBean(name="testBean")
@ViewScoped
public class testBean implements Serializable {

    private List<String> stringCollection;

    public List<String> getStringCollection() {
        return stringCollection;
    }

    public void …
Run Code Online (Sandbox Code Playgroud)

jsf facelets postconstruct view-scope

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

@ViewScoped在每个回发请求上调用@PostConstruct

这似乎不对.我正在清理我的代码,我只是注意到了这一点.每个ajax请求都会触发构造函数和@PostConstruct我的@ViewScopedbean.即使是简单的数据库分页也会触发它.

知道@ViewScoped@RequestScoped任何请求都要重建并且不应该重建.只有在通过GET重新加载完整页面之后.

jsf constructor postconstruct jsf-2 view-scope

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

如何在没有模型的Facelets中通过简单的for循环重复输出文本?

如何使用标准标签(ui:,h:etc)重复JSF中某些内容的输出?换句话说 - 如何在JSF中执行以下PHP代码?我马上想利用ui:repeat它,但它需要收集 - 我只有号码.

for ($i = 0; $i < 10; $i++) {
    echo "<div>content</div>";
}
Run Code Online (Sandbox Code Playgroud)

jsf facelets jsf-2 uirepeat

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