<%
@ page contentType
=
"
text/html;charset=gbk
"
pageEncoding
=
"
gbk
"
%>
<%
@ page language
=
"
java
"
%>
<%
@ taglib uri
=
"
http://jakarta.apache.org/struts/tags-bean
"
prefix
=
"
bean
"
%>
<%
@ taglib uri
=
"
http://jakarta.apache.org/struts/tags-html
"
prefix
=
"
html
"
%>
<%
@ page import
=
"
com.infogo.data.CodeManager
"
%>
<%
pageContext.setAttribute(
"
paymentMap
"
,CodeManager.getInstance().getPaymentStyle());
%>
<
html
>
<
head
>
<
title
>
JSP for newuserForm form
</
title
>
</
head
>
<
body
>
<
html:form
action
="/newuser.do"
>
name :
<
html:text
property
="name"
/><
html:errors
property
="name"
/><
br
/>
password :
<
html:text
property
="password"
/><
html:errors
property
="password"
/><
br
/>
sex : 男
<
html:radio
property
="sex"
value
="1"
/>
女
<
html:radio
property
="sex"
value
="2"
/><
html:errors
property
="sex"
/><
br
/>
<
html:select
property
="paymentStyle"
>
<
html:options
collection
="paymentMap"
property
="key"
labelProperty
="value"
/>
</
html:select
>
<
html:submit
/><
html:cancel
/>
</
html:form
>
</
body
>
</
html
>
package
com.infogo.data;
import
java.util.HashMap;
import
java.util.Map;
public
class
CodeManager
{
private
static
CodeManager _instance
=
new
CodeManager();
private
Map paymentStyle
=
new
HashMap();
private
CodeManager()
{
super
();
paymentStyle.put(
new
Integer(
1
),
"
网上支付
"
);
paymentStyle.put(
new
Integer(
2
),
"
信用卡
"
);
}
public
static
CodeManager getInstance()
{
return
_instance;
}
public
Map getPaymentStyle()
{
return
this
.paymentStyle;
}
}
//
Created by MyEclipse Struts
//
XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
package
com.infogo.struts.form;
import
javax.servlet.http.HttpServletRequest;
import
org.apache.struts.action.ActionErrors;
import
org.apache.struts.action.ActionForm;
import
org.apache.struts.action.ActionMapping;
/** */
/**
* MyEclipse Struts
* Creation date: 04-19-2006
*
* XDoclet definition:
* @struts.form name="newuserForm"
*/
public
class
NewuserForm
extends
ActionForm
{
//
--------------------------------------------------------- Instance Variables
/** */
/**
sex property
*/
private
Integer sex
=
new
Integer(
1
);
/** */
/**
password property
*/
private
String password;
/** */
/**
name property
*/
private
String name;
private
Integer paymentStyle;
//
--------------------------------------------------------- Methods
public
Integer getPaymentStyle()
{
return
paymentStyle;
}
public
void
setPaymentStyle(Integer paymentStyle)
{
this
.paymentStyle
=
paymentStyle;
}
/** */
/**
* Method validate
*
@param
mapping
*
@param
request
*
@return
ActionErrors
*/
public
ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request)
{
//
TODO Auto-generated method stub
return
null
;
}
/** */
/**
* Method reset
*
@param
mapping
*
@param
request
*/
public
void
reset(ActionMapping mapping, HttpServletRequest request)
{
//
TODO Auto-generated method stub
}
/** */
/**
* Returns the sex.
*
@return
Integer
*/
public
Integer getSex()
{
return
sex;
}
/** */
/**
* Set the sex.
*
@param
sex The sex to set
*/
public
void
setSex(Integer sex)
{
this
.sex
=
sex;
}
/** */
/**
* Returns the password.
*
@return
String
*/
public
String getPassword()
{
return
password;
}
/** */
/**
* Set the password.
*
@param
password The password to set
*/
public
void
setPassword(String password)
{
this
.password
=
password;
}
/** */
/**
* Returns the name.
*
@return
String
*/
public
String getName()
{
return
name;
}
/** */
/**
* Set the name.
*
@param
name The name to set
*/
public
void
setName(String name)
{
this
.name
=
name;
}
}
//
Created by MyEclipse Struts
//
XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
package
com.infogo.struts.action;
import
javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;
import
org.apache.struts.action.ActionForm;
import
org.apache.struts.action.ActionForward;
import
org.apache.struts.action.ActionMapping;
import
org.apache.struts.actions.MappingDispatchAction;
import
com.infogo.struts.form.NewuserForm;
/** */
/**
* MyEclipse Struts
* Creation date: 04-19-2006
*
* XDoclet definition:
* @struts.action path="/newuser" name="newuserForm" input="/user/user.jsp" scope="request" validate="true"
*/
public
class
NewuserAction
extends
MappingDispatchAction
{
//
--------------------------------------------------------- Instance Variables
//
--------------------------------------------------------- Methods
/** */
/**
* Method execute
*
@param
mapping
*
@param
form
*
@param
request
*
@param
response
*
@return
ActionForward
*/
public
ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
NewuserForm newuserForm
=
(NewuserForm) form;
System.out.println(
"
[SEX]:
"
+
newuserForm.getSex());
System.out.println(
"
[PAYMENTSTYLE]:
"
+
newuserForm.getPaymentStyle());
return
null
;
}
}
<?
xml version="1.0" encoding="UTF-8"
?>
<!
DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"
>
<
struts-config
>
<
form-beans
>
<
form-bean
name
="newuserForm"
type
="com.infogo.struts.form.NewuserForm"
/>
</
form-beans
>
<
action-mappings
>
<
action
attribute
="newuserForm"
input
="/user.jsp"
name
="newuserForm"
path
="/newuser"
scope
="request"
type
="com.infogo.struts.action.NewuserAction"
/>
<
action
forward
="/user.jsp"
path
="/toAdd"
/>
</
action-mappings
>
<
message-resources
parameter
="com.infogo.struts.ApplicationResources"
/>
</
struts-config
>
=======================
<%
@ page contentType
=
"
text/html;charset=gbk
"
pageEncoding
=
"
gbk
"
%>
<%
@ page language
=
"
java
"
%>
<%
@ taglib uri
=
"
http://jakarta.apache.org/struts/tags-bean
"
prefix
=
"
bean
"
%>
<%
@ taglib uri
=
"
http://jakarta.apache.org/struts/tags-html
"
prefix
=
"
html
"
%>
<%
@ taglib uri
=
"
http://struts.apache.org/tags-logic
"
prefix
=
"
logic
"
%>
<%
@ page import
=
"
com.infogo.data.CodeManager
"
%>
<%
pageContext.setAttribute(
"
paymentMap
"
,CodeManager.getInstance().getPaymentStyle());
pageContext.setAttribute(
"
pricingList
"
,CodeManager.getInstance().getPricingList());
%>
<
html
>
<
head
>
<
title
>
JSP for newuserForm form
</
title
>
</
head
>
<
body
>
<
html:form
action
="/newuser.do"
>
name :
<
html:text
property
="name"
/><
html:errors
property
="name"
/><
br
/>
password :
<
html:text
property
="password"
/><
html:errors
property
="password"
/><
br
/>
sex : 男
<
html:radio
property
="sex"
value
="1"
/>
女
<
html:radio
property
="sex"
value
="2"
/><
html:errors
property
="sex"
/><
br
/>
<
html:select
property
="paymentStyle"
>
<
html:options
collection
="paymentMap"
property
="key"
labelProperty
="value"
/>
</
html:select
>
<
html:submit
/><
html:cancel
/>
</
html:form
>
<%
--
<
logic:iterate id
=
"
pricing
"
collection
=
"
<%=CodeManager.getInstance().getPricingList()%>
"
>
--
%>
<
logic:iterate
id
="pricing"
name
="pricingList"
>
<
bean:write
name
="pricing"
property
="pricingName"
/>
<
html:link
target
="_blank"
action
="/user/toAdd.do"
paramId
="pid"
paramName
="pricing"
paramProperty
="id"
>
pricing
</
html:link
>
</
logic:iterate
>
</
body
>
</
html
>
posted on 2006-04-20 15:43
北国狼人的BloG 阅读(585)
评论(0) 编辑 收藏 所属分类:
达内学习总结