我试图运行简单的JSF应用程序(Java ),在windows中使用JDK11.0.4和apache 12.1单击按钮时,将数据从一个页面发送到另一个页面。当我清理构建项目时,它会显示“error:/p:不允许目标11”。
JSF框架版本
package model;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
@Named(value = "bean1")
@RequestScoped
public class bean1 {
String nm;
public String getNm() {
return nm;
}
public void setNm(String nm) {
this.nm = nm;
}
/**
* Creates a new instance of bean1
*/
public bean1() {
}
}<?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://xmlns.jcp.org/jsf/html"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
<title>Page 1</title>
</h:head>
<h:body>
<h2>Hello Page 1</h2>
<h:form>
<h:outputLabel for="txtName"></h:outputLabel>
<h:inputText id="txtName" value="#{bean1.nm}" />
#{bean1.nm}
<h:commandButton value="SEND" />
</h:form>
</h:body>
</html>3.page2.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:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Page2</title>
</h:head>
<h:body>
#{bean1.nm}
</h:body>
</html>4.web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<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>*.jsf</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
</web-app>5.faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.3"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_3.xsd">
</faces-config>它仍然会被部署并运行,在浏览器上运行之后,当我单击按钮page1.xhtml时会出现以下错误
发布于 2021-04-19 15:46:30
现在,在创建一个具有新项目名称.Keep的新java应用程序之后,这个问题已经解决了--请记住,不要使用与当前项目提供的名称相同的名称,例如:如果我的这个项目名是JSFDemo,那么新的项目名应该是JSFDemo以外的其他名称,因此只能解决:)
https://stackoverflow.com/questions/67120828
复制相似问题