reguser.jsp(唯一的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>RegUser</title>
<html:base/>
</head>
<body bgcolor="white">
<html:errors/>
<html:form action="/regUserAction" focus="logname">
<table border="0" width="100%">
<tr>
<th align="right">
Logname:
</th>
<td align="left">
<html:text property="logname" size="20" maxlength="20"/>
</td>
</tr>
<tr>
<th align="right">
Password:
</th>
<td align="left">
<html:password property="password" size="20" maxlength="20"/>
</td>
</tr>
<tr>
<th align="right">
E-mail:
</th>
<td align="left">
<html:text property="email" size="30" maxlength="50"/>
</td>
</tr>
<tr>
<td align="right">
<html:submit property="submit" value="Submit"/>
</td>
<td align="left">
<html:reset/>
</td>
</tr>
</table>
</html:form>
</body>
</html:html>
<%@ 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>RegUser</title>
<html:base/>
</head>
<body bgcolor="white">
<html:errors/>
<html:form action="/regUserAction" focus="logname">
<table border="0" width="100%">
<tr>
<th align="right">
Logname:
</th>
<td align="left">
<html:text property="logname" size="20" maxlength="20"/>
</td>
</tr>
<tr>
<th align="right">
Password:
</th>
<td align="left">
<html:password property="password" size="20" maxlength="20"/>
</td>
</tr>
<tr>
<th align="right">
E-mail:
</th>
<td align="left">
<html:text property="email" size="30" maxlength="50"/>
</td>
</tr>
<tr>
<td align="right">
<html:submit property="submit" value="Submit"/>
</td>
<td align="left">
<html:reset/>
</td>
</tr>
</table>
</html:form>
</body>
</html:html>
解决方案 »
- 我网站老是内存溢出,请大家推荐好用的!
- java 表单提交乱码问题
- 计划写工具类统计每个 SQL/Request 的执行时间,有好思路么?
- 同一个类中有两个manager类,操作两个不同表,如果保证是同一个事务[采用spring+hibernate]
- 公司要签订三年合同?一定要呆满三年吗?要是中途离职会有什么后果?
- 启动我的JBOSS到底出了什么错?
- 奇怪的synchronized问题
- 救命啊...关于在LINUX下显示中文问题
- 安装了JBULID7,要学J2EE,还用不用下载那个J2EE的JDK!(好大啊!!)^_^
- 免费送内部价值200元的50张北风网的学习卡
- EJB和struts
- 为什么编译总出错“not a statement”??? 谢谢
<?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"><!--
This is the Struts configuration file for the example application,
using the proposed new syntax.
-->
<struts-config>
<form-beans>
<form-bean name="regUserForm" type="org.cjea.Struts.example.RegUserForm"/>
</form-beans><action-mappings>
<action path="/regUserAction"
type="org.cjea.Struts.example.RegUserAction"
attribute="regUserForm"
scope="request"
validate="false">
<forward name="failure" path="/messageFailure.jsp"/>
<forward name="success" path="/messageSuccess.jsp"/>
</action>
</action-mappings>
</struts-config>
package org.cjea.Struts.example;import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;public final class RegUserForm extends ActionForm{ private String logname="";
private String password="";
private String email=""; public RegUserForm(){
logname = null;
password = null;
email = null;
} public String getLogName() {
return this.logname;
}
public void setLogName(String logname) {
this.logname = logname;
}
public void setPassWord(String password) {
this.password = password;
}
public String getPassWord() {
return this.password;
}
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return this.email;
} public void reset(ActionMapping mapping, HttpServletRequest request)
{
logname = null;
password = null;
email = null;
}
}
<form-bean name="regUserForm" type="org.cjea.Struts.example.RegUserForm"/>
</form-beans>
不是空啊,有东西的
type="org.cjea.Struts.example.RegUserAction"
attribute="regUserForm"
scope="request"
validate="false">
<forward name="failure" path="/messageFailure.jsp"/>
<forward name="success" path="/messageSuccess.jsp"/>
</action>
我把这里的attribute改成name则出现下列错误提示;No getter method for property logname of bean org.apache.struts.taglib.html.BEAN
这是怎么回事,事事上getter方法已经有了
先改成
<html:form action="/regUserAction.do" focus="logname">
再说
<action path="/regUserAction"
name="regUserForm"//if you haven't asigned this one,system will find null
type="org.cjea.Struts.example.RegUserAction"
attribute="regUserForm"
scope="request"
validate="false">
<forward name="failure" path="/messageFailure.jsp"/>
<forward name="success" path="/messageSuccess.jsp"/>
</action>
怎么回事
return this.logname;
}
public void setLogName(String logname) {
this.logname = logname;
}
中所有Name改为name,也就是说N小写
1、所有的属性必须以小写字母开始
2、Set和Get函数将属性的第一个字母改为大写
在本例中,因为属性全是小写,所以Set只能第一个字母是大写。
如果定义属性为passWord,则Set函数为setPassWord(),Get函数为getPassWord()