struts的问题,急啊!!! HTTP 404 - 未找到文件 !!!在线等
本人刚刚接触struts,照书上写了一个示例程序!!!起初遇到一些问题,在google中但能搜到,但这个问题实在是找不到答案,只得麻烦大家了,
写一个createuser.jsp要求输入uid,password,age,之后显示反馈页面viewuser.jsp.其中用到的bean写好均编译通过,User是一个值对象类,UserForm接收表单提交的数据,UserBean封装连接数据库和插入数据操作,UserAction用于执行业务逻辑,其代码如下,
package com.cstmail.login;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class UserAction extends Action
{
public ActionForward perform(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
{
UserForm f=(UserForm)form;
try
{
UserBean bean=new UserBean();
bean.addUser(f.getUser());
}
catch(Exception e)
{
e.printStackTrace();
}
request.setAttribute("User",f.getUser());
return(mapping.findForward("userCreated"));
}
}
其中struts-config.xml如下:
<struts-config>
<form-beans>
<form-bean name="userForm" type="com.cstmail.login.UserForm"/>
</form-beans>
<global-forwards>
<forward name="userCreated" path="/viewuser.jsp"/>
</global-forwards>
<action-mappings>
<action path="/createuser"
type="com.cstmail.login.UserAction"
name="userForm"
scope="request"
validate="true"
input="/createuser.jsp">
</action>
<forward name="userCreated" path="/viewuser.jsp"/>
</action-mappings>
<message-resources parameter="ApplicationResources"/>
</struts-config>
其中createuser.jsp如下:
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<%@ taglib uri="/struts-bean" prefix="bean"%>
<%@ taglib uri="/struts-html" prefix="html"%>
<html:html locale="true">
<head>
<title>RegUser</title>
<html:base/>
</head>
<body bgcolor="white">
<html:errors/>
<html:form action="createuser.do" method="GET">
<table border="0" width="100%">
<tr>
<th align="right">
UID:
</th>
<td align="left">
<html:text property="user.uid" size="20" maxlength="20"/>
</td>
</tr>
<tr>
<th align="right">
Password:
</th>
<td align="left">
<html:password property="user.password" size="20" maxlength="20"/>
</td>
</tr>
<tr>
<th align="right">
age:
</th>
<td align="left">
<html:text property="user.age" 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>
在ie中发出请求,能显示createuser.jsp页面,但提交后出现错误如下:
您要查看的网页可能已被删除、名称已被更改,或者暂时不可用。
--------------------------------------------------------------------------------
请尝试以下操作:
如果您已经在地址栏中输入该网页的地址,请确认其拼写正确。
打开 localhost 主页,然后查找指向您感兴趣信息的链接。
单击后退按钮,尝试其他链接。
单击搜索,寻找 Internet 上的信息。
HTTP 404 - 未找到文件
Internet Explorer
实在是不知道是什么原因啊,郁闷中,望高手指点.不胜感激啊,在线等!!!!