【发布时间】:2014-05-25 22:01:24
【问题描述】:
假设您有一个在线表格,您必须在其中注册才能投票:
<html>
<head>
</head>
<body>
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname"><br>
Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip: <input type="text" name="zip"><br>
Phone Number: <input type="text" name="phone"><br>
Affiliation:<br>
<input type="radio" name="affil" value="demo">Democrat<br>
<input type="radio" name="affil" value="green">Green Party<br>
<input type="radio" name="affil" value="liber">Liberterian<br>
<input type="radio" name="affil" value="repub">Republican<br>
<input type="radio" name="affil" value="None">Unafiiliated<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
我想在表单中的某个地方放置文本
“下一次选举:[日期值]”
但是我不想在 HTML 中硬编码日期,而是希望将日期插入到我的 web.xml 文件中,然后让 HTML 文件引用该日期。
但是,我对 XML 以及它如何与 HTML 连接非常缺乏经验。我如何在 XML 中创建一个日期,然后让 HTML 文件引用它?
这是我当前的“web.xml”文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
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-app_3_0.xsd">
<!-- Tell faces what extension it should be using to find files. -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Turn on debugging for faces. -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- This section loads the servlet that process faces into your app. -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- This tells the server where to send requests for faces pages. -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
【问题讨论】: