这只是我现在的好奇心.在Eclipse中,这是在新的Facelet模板<head>上定义的部分,但是对于大多数模板来说是同样的事情:
<!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:ui="http://java.sun.com/jsf/facelets">
<head>
..
</head>
Run Code Online (Sandbox Code Playgroud)
我想在其上使用更清晰的代码,所以我改为:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
..
</head>
Run Code Online (Sandbox Code Playgroud)
它在开发中运行良好,但我想知道这种方法是否会在未来通过许多浏览器或设备(移动)提出任何问题.
是否可以在xhtml文件中内联CSS的类定义?
我的意思是,把一些像:
p.first{ color: blue; }
p.second{ color: red; }
Run Code Online (Sandbox Code Playgroud)
在我的页面内,不在单独的CSS文件中.
我刚刚开始使用JSF 2.0,并且我在一开始就遇到了问题.不解析JSF标记.
以下是一些细节.希望有人可以提供帮助,因为没有任何相关的SO问题能解决我的问题.
为hello.jsp
<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:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<f:view>
asd
<h:inputText value="asd" label="UserName"></h:inputText>
</f:view>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
我在导航时看到的内容 http://localhost:8080/JSFDeneme/pages/hello.jsp
只有明文 asd
查看源代码 http://localhost:8080/JSFDeneme/pages/hello.jsp
完全相同的内容 hello.jsp
<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:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<f:view>asd
<h:inputText value="asd" label="UserName"></h:inputText>
</f:view>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<display-name>JSFDeneme</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>/pages/*</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> …Run Code Online (Sandbox Code Playgroud) 如何在的消息中添加新行<p:confirm>?
<p:confirm header="COnfirmation"
message="Are you sure you want to continue? Bla bla bla"
icon="ui-icon-alert" />
Run Code Online (Sandbox Code Playgroud)
我希望将“ Bla bla bla”换行。
在我的Facelets模板中,我使用了XHTML doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Run Code Online (Sandbox Code Playgroud)
我想根据一般建议将其更改为HTML5 doctype:
<!DOCTYPE html>
Run Code Online (Sandbox Code Playgroud)
但是,JSF抛出了一个解析错误:
javax.faces.view.facelets.FaceletException:Error Parsing /template.xhtml:Error Traced [line:42]实体"nbsp"被引用,但未声明.
然后不解析HTML 实体.该实体使用如下:
<p:menuitem value=" My menuitem">
Run Code Online (Sandbox Code Playgroud)
这是怎么造成的,我该如何解决?
我正在寻找关于JSF的HTML5标签H5的更多阅读.我看过IBM的JSF 2 fu文章,但除了关于"html5的承诺"等的演示文稿和幻灯片放映之外,还没有真正看到过.
谁能建议一些推荐的技术阅读?
我试图让JSF设置使用具有html扩展名的文件.
如果我使用.xhtml模式(<url-pattern>*.xhtml</url-pattern>)并使用xhtml扩展名命名我的文件,那么页面会正确加载并进行解析.
但是,如果我将其更改为<url-pattern>*.html</url-pattern>并使用.html扩展名命名文件,则会出现500错误:
The server encountered an internal error () that prevented it from fulfilling this request.
Exception: java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
服务器日志:
WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getPhaseMapForReading(ELFlash.java:748)
at com.sun.faces.context.flash.ELFlash.isEmpty(ELFlash.java:466)
at com.sun.faces.facelets.util.DevTools.writeVariables(DevTools.java:318)
at com.sun.faces.facelets.util.DevTools.writeVariables(DevTools.java:208)
at com.sun.faces.facelets.util.DevTools.debugHtml(DevTools.java:123)
at com.sun.faces.renderkit.RenderKitUtils.renderHtmlErrorPage(RenderKitUtils.java:1139)
at com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:249)
at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:136)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) …Run Code Online (Sandbox Code Playgroud) 我需要使用客户端发送的参数来更改我的网站的上下文.
例如,如果我打电话给http://localhost:8084/JSF/我加载模板index.xhtml上的"主页"页面content(默认情况下).但是,如果我打电话http://localhost:8084/JSF/index.xhtml?page=profile,我需要一种切换index.xhtml,并在我的content区域中包含/插入配置文件模板(或定义配置文件的页面).
我想我需要管理一个servlet才能做到这一点,因为我不认为我可以在index.xhtml中创建一种swith.所以我认为我需要加载一些模板而不是另一个.
我需要使用哪个servlet?或者我需要创建自己的Servlet才能执行此操作?
干杯
更新(在BalusC的建议之后添加)
package Beans;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ManagedBean;
@ManagedBean(name="selector")
@ManagedProperty(value="#{param.page}")
public class Selector {
private String page;
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
}
Run Code Online (Sandbox Code Playgroud)
template.xhtml
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title><ui:insert name="title">Facelets Template</ui:insert></title>
</h:head>
<h:body>
<ui:insert name="login_homepage">Box Content Here</ui:insert>
<ui:insert name="content_homepage">Box Content …Run Code Online (Sandbox Code Playgroud) 我最近开始使用JSF 2.0开发一个Web应用程序,但是我是Web开发的新手,并且该领域(即使在限制JVM解决方案的情况下)变得非常庞大......选择的技术数量有点压倒性的.
我的担忧/问题是,混合/整合以下技术是否可行/建议?
如果是这样的话,在与网页设计师合作时,JSF 2.0对我来说会变得更加困难.例如,当将Web设计集成到应用程序中时,我想我将不得不做一些修改:插入JSF标记和EL表达式,以某种特殊方式处理JavaScript(?),处理HTML标记不兼容性(?)等.
以下问题很有帮助,但没有澄清一切:
提前致谢