regedit.jsp
<%@ 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"%>
<html>
<head>
<title>JSP for RegeditForm form</title>
</head>
<body>
<html:form action="/regedit">
useraddr : <html:text property="useraddr"/><html:errors property="useraddr"/><br/>
username : <html:text property="username"/><html:errors property="username"/><br/>
id : <html:text property="id"/><html:errors property="id"/><br/>
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
struts-config.xml
<?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>
<data-sources />
<form-beans >
<form-bean name="regeditForm" type="org.rockie.struts.form.RegeditForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="regeditForm"
input="/regedit.jsp"
name="regeditForm"
path="/regedit"
scope="session"
type="org.rockie.struts.action.RegeditAction">
<forward
name="show"
path="/show.jsp"
redirect="true" /> //地址不变
</action>
</action-mappings>
<message-resources parameter="org.rockie.struts.ApplicationResources" />
</struts-config>
RegeditFrom.java
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
username="rockie";
id="s00";
useraddr="sz";
}
RegeditAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
RegeditForm regeditForm = (RegeditForm) form;// TODO Auto-generated method stub
return mapping.findForward("show");
show.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>My JSP 'show.jsp' starting page</title>
</head>
<jsp:useBean id="regeditForm" class="org.rockie.struts.form.RegeditForm" scope="session"/>
<body>
id:<jsp:getProperty property="id" name="regeditForm"/><br>
username:<jsp:getProperty property="username" name="regeditForm"/><br>
useraddr:<jsp:getProperty property="useraddr" name="regeditForm"/><br>
</body>
</html>
ps:此帖绝对是本人原创...
转载时..
请注明:
转至http://blog.csdn.net/Kipen/ 作者:rockie(石の頭丶)
请尊重他人的劳动果实..
谢谢..
--by rockie(石の頭丶)
本文介绍了一个使用Struts框架实现的简单注册表单示例,包括JSP页面展示、Struts配置文件设置及Java后端处理逻辑。通过这个例子可以了解Struts框架的基本用法。

4673

被折叠的 条评论
为什么被折叠?



