Struts原理與實踐(2)

2021-04-28 17:24:02 字數 2840 閱讀 9613

<%@ page contenttype="text/html; charset=utf-8" %>

<%@ taglib uri="/web-inf/struts-bean.tld"

prefix="bean" %>

<%@ taglib uri="/web-inf/struts-html.tld"

prefix="html" %>

<

html

>

<

head

>

<

title

>

<

bean:message

key="logon.jsp.title"

/>

title

>

<

html:base

/>

head

>

<

body

>

<

h3>

<

bean:message

key="logon.jsp.page.heading"

/>

h3>

<

html:errors

/>

<

html:form

action="/logonaction.do"

focus="username"

>

<

table

border="0"

width="100%"

>

<

tr>

<

thalign="right"

>

<

bean:message

key="logon.jsp.prompt.username"

/>

th>

<

tdalign="left"

>

<

html:text

property="username"

/>

td>

tr>

<

tr>

<

thalign="right"

>

<

bean:message

key="logon.jsp.prompt.password"

/>

th>

<

tdalign="left"

>

<

html:password

property="password"

/>

td>

tr>

<

tr>

<

tdalign="right"

>

<

html:submit

>

<

bean:message

key="logon.jsp.prompt.submit"

/>

html:submit

>

td>

<

tdalign="left"

>

<

html:reset

>

<

bean:message

key="logon.jsp.prompt.reset"

/>

html:reset

>

td>

tr>

table

>

html:form

>

body

>

html

>

main.jsp的**清單如下:

<%@ page contenttype="text/html; charset=utf-8" %>

<%@ taglib uri="/web-inf/struts-bean.tld"

prefix="bean" %>

<%@ taglib uri="/web-inf/struts-logic.tld"

prefix="logic" %>

<

html

>

<

head

>

<

title

>

<

bean:message

key="main.jsp.title"

/>

title

>

<

html:base

/>

head

>

<

body

>

<

logic:present

name="userinfoform"

>

<

h3>

<

bean:message

key="main.jsp.welcome"

/>

<

bean:write

name="userinfoform"

property="username"

/>!   

h3>

logic:present

>

body

>

html

>

首先,我們看一下logon.jsp檔案,會發現它有這麼兩個鮮明的特點:一是檔案頭部有諸如:

這樣的指令**,他們的作用就是指示頁面要用到struts的自定義標籤,標籤庫uri是乙個邏輯引用,標籤庫的描述符(tld)的位置在web.xml檔案中給出,見上篇文章的配置部分。struts的標籤庫主要由四組標籤組成,它們分別是:

Struts原理與實踐(2)

page contenttype text html charset utf 8 taglib uri web inf struts bean.tld prefix bean taglib uri web inf struts html.tld prefix html html head title...

Struts原理與實踐(2)

struts原理與實踐 2 taglib uri web inf struts bean.tld prefix bean taglib uri web inf struts html.tld prefix html main.jsp的 清單如下 page contenttype text html ...

Struts原理與實踐(2)

taglib uri web inf struts bean.tld prefix bean taglib uri web inf struts html.tld prefix html main.jsp的 清單如下 page contenttype text html charset utf 8 ...