我的网络应用程序包含3页:
我有两个 javaBean 类:
1.webTimeBean 2.userBean
webtimeBean 类为@ApplicationScoped
。
userBean 类为@SessionScoped
。
我还有用于SQL请求的类和用户信息的用户类。
我有导航问题。
用户登录(index.xhtml)后,欢迎页面正确加载数据库中的数据。
然后用户可以单击下一轮链接,而是导航到nextround.xjtml
应用程序将他发送回index.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"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
<h:head>
<title>Web TIme : A simple example Title</title>
<meta http-equiv="refresh" content="60"/>
</h:head>
<h:body>
<div class="w3-container w3-light-grey w3-border">
<p>Today : #{webTimeBean.time}</p>
</div>
<h:form>
<br></br>
<h:inputText value="#{userBean.email}" class="w3-input" />
<h:inputText value="#{userBean.password}" class="w3-input" />
<h:commandButton value="Log In" class="w3-btn-block w3-teal" action="#{userBean.verifyLogin()}" />
</h:form>
</h:body>
</html>
<?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:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
<h:head>
<title>Goalim Game </title>
<meta http-equiv="refresh" content="300"/>
</h:head>
<h:body>
<div class="w3-container w3-light-grey w3-border">
<p>Today : #{webTimeBean.time}</p>
</div>
<table class="w3-table w3-bordered w3-striped">
<tr>
<th>User Name</th>
<th>Score</th>
</tr>
<ui:repeat var="elem" value="#{userBean.tblScore}" >
<tr>
<td>
<h:outputText value="#{elem.userName}" />
</td>
<td>
<h:outputText value="#{elem.totalPoints}" />
</td>
</tr>
</ui:repeat>
</table>
<form>
<h:commandButton value="Next Round" class="w3-btn-block w3-teal" action="/nextround.xhtml" />
</form>
</h:body>
</html>
<?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:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
<h:head>
<title>Web TIme : A simple example Title</title>
<meta http-equiv="refresh" content="60"/>
</h:head>
<h:body>
<div class="w3-container w3-light-grey w3-border">
<p>Today : #{webTimeBean.time}</p>
<p>Hello : #{userBean.userName}</p>
</div>
</h:body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="3.1">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<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>
</servlet-mapping>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<resource-ref>
<description>postgress database</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>