b>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>
实例学习Struts(2)
时间:2010-12-10
Struts 的配置文件 logonApp/WEB-INF/struts-config.xml 如下:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>
<struts-config>
<form-beans>
<form-bean name="logonForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
</form-beans>
<global-forwards>
<forward name="success" path="/main.jsp"/>
<forward name="logoff" path="/logoff.do"/>
</global-forwards>
<action-mappings>
<action path="/logon"
type="org.monotonous.struts.LogonAction"
name="logonForm"
scope="session"
input="logon">
</action>
<action path="/logoff"
type="org.monotonous.struts.LogoffAction">
<forward name="success" path="/index.jsp"/>
</action>
</action-mappings>
<controller>
<!-- The "input" parameter on "action" elements is the name of a
local or global "forward" rather than a module-relative path -->
<set-property property="inputForward" value="true"/>
</controller>
<message-resources parameter="org.monotonous.struts.ApplicationResources"/>
</struts-config>
创建 View
现在回到 Eclipse,建立一个新页面 index.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html locale="true">
<head>
<title><bean:message key="index.title" /></title>
<html:base/>
</head>
<body>
<html:errors/>
<html:form action="/logon">
<bean:message key="prompt.username"/>
<html:text property="username"/>
<br/>
<bean:message key="prompt.password"/>
<html:password property="password"/>
<br/>
<html:submit>
<bean:message key="index.logon"/>
</html:submit>
</html:form>
</body>
</html:html>
实例学习Struts(3)
时间:2010-12-10
成功登录后的页面 main.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="j
|