急!急!高分求教struts路径问题!!!!!!

lenhan12345 2006-11-17 09:07:48
小弟写了一个简单的STRUTS程序,,以前也用过,但是这次死活说路径找不到。。
错误代码如下:
HTTP Status 404 - /usernameDel.do

--------------------------------------------------------------------------------

type Status report

message /usernameDel.do

description The requested resource (/usernameDel.do) is not available.


我的前目录结构如下:
WorkSpace\xygc\WebRoot\User_ListForm.jsp

User_ListForm.jsp源代码如下::
<%@ page language="java" contentType="text/html;charset=GB2312" %>
<%@ page import="com.lztx.xygc.util.Pagination"%>
<%@ page import="com.lztx.xygc.util.DbManager"%>
<%@ page import="com.lztx.xygc.util.DbUtil"%>
<%@ page import="com.lztx.xygc.util.DateUtil"%>
<%@ include file="include/taglibs.jsp"%>
<%
request.setCharacterEncoding("GB2312");
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1);
response.setDateHeader("max-age", 0);
%>

<html>
<head>
<LINK href="css/css.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户管理</title>
<script language="JavaScript">
/*
* 删除
*/
function selectItem() {
var obj = document.getElementsByTagName("input");
if (obj) {
for (var i = 0; i < obj.length; i++) {
if (obj[i].type == "checkbox")
obj[i].checked = !obj[i].checked;
}
}
}

function getCheckValue() {
var rtn = new Array();
var obj = document.getElementsByTagName("input");
if (obj) {
for (var i = 0; i < obj.length; i++) {
if (obj[i].type == "checkbox")
if (obj[i].checked) rtn[rtn.length] = obj[i].value;
}
}
return rtn;
}

function formEdit() {
document.all.delValue.value = getCheckValue();

if (document.all.delValue.value.length == 0 ) {
alert("请选择您要删除的记录!");
return false;
}
alert(document.all.delValue.value);
if (window.confirm("你确定要删除选中的记录吗?"))
document.forms[0].submit();
}
</script>

</head>
<body >
<!--======导航条=======-->
<form action="/usernameDel.do?method=userDel" method="post">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="Images/topbg.png">
<tr height="30">
<td height="30" class="NavFont" > 系统管理>用户管理</td>
<td align="right" >
<span style="padding-right:5px">
<A Href="User_NewForm.jsp" class="Link2">添加</A>
<A Href="#" class="Link2">激活</A>
<A Href="#" class="Link2">锁定</A>
<A Href="#" onClick="formEdit(); return false" class="Link2">删除</A>
<A Href="#" onClick="selectItem();return false" class="Link2">反选</A>
</span>
</td>
<td width="10"> </td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#AFCFEF">
<td align="center" ><%=DateUtil.GetDateFormat(arrayStr[i][6],"yyyy-MM-dd")%></td>
<td align="center" ><input type="checkbox" name="checkbox" value="<%=arrayStr[i][0]%>"></TD>
</tr>

<%
} else {
%>
<tr bgcolor="#FFFFFF" height="23" >
<td> </td><td > </td><td > </td> <td > </td><td > </td><td > </td><td > </td>
</tr>
<%
}
}
%>

<input type="hidden" name="delValue" value="">
</form>
</body>
</html>

web.xml的代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>com.lztx.xygc.util.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/FCKeditor.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/FCKeditor.tld</taglib-location>
</taglib>

</web-app>

struts-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-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<!-- 用户删除 -->

<action path = "/usernameDel"
type = "com.lztx.xygc.user.action.UserAction"
validate = "false"
parameter = "method"

>
<forward name="userDelSucc" path="/User_ListForm.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.lztx.xygc.struts.application" />
</struts-config>


UserAction的代码如下:

package com.lztx.xygc.user.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.actions.DispatchAction;
import com.lztx.xygc.user.model.userModel;
public class UserAction extends DispatchAction{
Log log = LogFactory.getLog("UserAction");
public ActionForward userDel(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
{
try{
String delValue = request.getParameter("delValue");
userModel usermodel = new userModel();
usermodel.userListDel(delValue);
}catch(Exception e)
{
e.printStackTrace();
}
return(mapping.findForward("userDelSucc"));
}
}

感觉以上的配置并没有错呀?为什么删除时会出现这个错误呢?偶是新手。。请高手指教一下。在线急等!!
...全文
135 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
nccxl 2006-11-17
  • 打赏
  • 举报
回复
不写应该表示根目录吧。
lenhan12345 2006-11-17
  • 打赏
  • 举报
回复
./代表当前路径,也可以不写.不写的话.为什么就出错了呢??
lenhan12345 2006-11-17
  • 打赏
  • 举报
回复
试试看...
tcmis 2006-11-17
  • 打赏
  • 举报
回复
/usernameDel.do
前面加个点
./usernameDel.do试试

或者是
<a href="<%=request.getContextPath()%>/usernameDel.do">点击</a>
lenhan12345 2006-11-17
  • 打赏
  • 举报
回复
应当不是tomcat/conf/server.xml的配置问题吧...因为我都可以从数据库里面取出值来的/!!!!1
jsjzzh 2006-11-17
  • 打赏
  • 举报
回复
怀疑你tomcat配置问题,看看tomcat/conf/server.xml中有没有关于你这个工程的配置。

可以找一找类似的文章配一下。
wmzsl 2006-11-17
  • 打赏
  • 举报
回复
用绝对路径!别用相对路径! 你要是用相对路径必须使用struts的标签,如果不使用标签你就要用request.getContextPath()好像是这么一个方法然后在加上/abc.do什么的才可以!

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧