| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1212 人关注过本帖
标题:struts标签写的表单无法显示
只看楼主 加入收藏
dbgcarlos
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-2-7
收藏
 问题点数:0 回复次数:7 
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
天涯海角
Rank: 2
等 级:新手上路
威 望:3
帖 子:507
专家分:0
注 册:2005-10-21
收藏
得分:0 
servlet 异常,说明你的insert.do
获取信息不正确或读取信息不正确,请检查一下。

我的未来不是梦!
2007-06-12 21:54
dbgcarlos
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-2-7
收藏
得分:0 
没有啊,我连表单都没有显示啊,根本连提交都没有提交,actionForm里怎么可能接收到数据呢,读不到任何信息啊,我用的ide是eclipse3.2.0+myeclipse5.1.1ga

2007-06-13 08:15
风月_无边
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:60
帖 子:2960
专家分:652
注 册:2007-1-19
收藏
得分:0 

虽然你没有提交,它也是会检查的!


我的网站 http://www.
2007-06-13 08:30
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
lican
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-12-31
收藏
得分:0 

因为你没有创建 InsertAction ,struts首先运行的是Action,因为它是处理类,根据配置文件来进行处理,你没有这个Action,当然会报错,不信你创一个Action试试看


2007-06-13 23:19
yuexinlin200
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-6-12
收藏
得分:0 
action类写错了

FastCode Web快速开发工具,www.
2007-06-15 10:14
pilou5400
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-11-7
收藏
得分:0 
你把这些东西都去干净就对了。
<html:errors property="XXX" />
2007-06-21 22:24
快速回复:struts标签写的表单无法显示
数据加载中...
 
   



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

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