标题:struts标签写的表单无法显示
取消只看楼主
dbgcarlos
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-2-7
 问题点数:0 回复次数:2 
struts标签写的表单无法显示

下面是我用struts标签写的表单:
<%@ page language="java" pageEncoding="gbk"%>

<%@ 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://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
prefix="tiles"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template"
prefix="template"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested"
prefix="nested"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title>insert.jsp</title>
</head>

<body bgcolor="pink">
<html:form action="insert.do" method="post">
id:<html:text property="id"></html:text>
<html:errors property="nid" />
<br>
name:<html:text property="name"></html:text>
<br>
<html:errors property="nname" />
<br>
address:<html:text property="address"></html:text>
<br>
email:<html:text property="email"></html:text>
<br>

<html:submit value="提交" />

<html:reset value="重置" />
</html:form>
</body>
</html:html>

启动服务器之后跳出下列错误:


好像是提示action mapping没有找到或者是没有找到formbean中的集合
我连表单提交都没有提交怎么会有集合元素呢?
到底怎么回事啊?

搜索更多相关主题的帖子: struts jakarta 表单 apache 
2007-06-12 12:34
dbgcarlos
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-2-7
得分:0 
没有啊,我连表单都没有显示啊,根本连提交都没有提交,actionForm里怎么可能接收到数据呢,读不到任何信息啊,我用的ide是eclipse3.2.0+myeclipse5.1.1ga

2007-06-13 08:15
dbgcarlos
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-2-7
得分:0 

这是我的formbean
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.zwj.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;
import org.apache.struts.action.ActionMessage;

/**
* MyEclipse Struts
* Creation date: 06-12-2007
*
* XDoclet definition:
* @struts.form name="InsertForm"
*/
public class InsertForm extends ActionForm {
/*
* Generated fields
*/

/** address property */
private String address;

/** email property */
private String email;

/** name property */
private String name;

/** id property */
private String id;

/*
* Generated Methods
*/

/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (id == null || id.trim().length() == 0) {
ActionMessage message = new ActionMessage("error.id");
errors.add("nid", message);
}
if (name == null || name.trim().length() == 0) {
ActionMessage message = new ActionMessage("error.name");
errors.add("nname", message);
}

return errors;
}

/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}

/**
* Returns the address.
* @return String
*/
public String getAddress() {
return address;
}

/**
* Set the address.
* @param address The address to set
*/
public void setAddress(String address) {
this.address = address;
}

/**
* Returns the email.
* @return String
*/
public String getEmail() {
return email;
}

/**
* Set the email.
* @param email The email to set
*/
public void setEmail(String email) {
this.email = email;
}

/**
* 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;
}

/**
* Returns the id.
* @return String
*/
public String getId() {
return id;
}

/**
* Set the id.
* @param id The id to set
*/
public void setId(String id) {
this.id = id;
}
}

下面是我的sturts-config.xml;
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data-sources />
<form-beans >
<form-bean name="InsertForm" type="com.zwj.struts.Form.InsertForm" />

</form-beans>

<global-exceptions />
<global-forwards >
<forward name="fail" path="/error.jsp" />
</global-forwards>
<action-mappings >
<action
attribute="InsertForm"
input="/insert.jsp"
name="InsertForm"
path="/insert"
scope="request"
type="com.zwj.struts.Action.InsertAction" >
<forward name="suc" path="/isuccess.jsp" />
</action>


</action-mappings>

<message-resources parameter="com.zwj.struts.Form.ApplicationResources" />
</struts-config>
我没有发现什么错误啊


2007-06-13 10:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-146768-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.096413 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved