我的信息管理模块放在WebRoot/news下,
struts_config.xml的配置信息如下:
    <action
      path="/news/info_man"
      type="cn.com.ioas.news.action.Info_manAction"
      validate="false">
      <forward name="news/info_man" path="/news/info_man.jsp" />
    </action>Info_manAction.java源代码如下:
public class Info_manAction extends Action {
/*
 * Generated Methods
 */ /**
 * Method execute
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 验证登录以及权限
String isrights = Check.isRights(request, response);
if (!isrights.equals("OK")) {
cn.com.ioas.ugp.security.Check.redirectErr(request, response,
"err.do?errmsg=" + isrights);
return null;
} else {
// 业务逻辑
boolean isdata = false;
int pageSize = cn.com.ioas.common.Constants.PAGE_SIZE;
String page = request.getParameter("page");
page = (page == null) ? "1" : page.trim(); // 构建查询过滤语句-start
String newsClass = request.getParameter("newsclass");
String keywords = request.getParameter("keywords");
String sqlFilter = "";
if (newsClass == null) {
newsClass = "0";
}
if (keywords != null && !keywords.equals("")) {
keywords = ParamUtil.sqlStrchop(keywords);
sqlFilter = " and (a.title like '%" + keywords
+ "%' or a.content like '%" + keywords
+ "%' or a.pubuser like '%" + keywords
+ "%' or a.infofrom like '%" + keywords
+ "%' or a.pubdate like '%" + keywords + "%')";
} else {
keywords = "";
}
if (!newsClass.equals("0")) {
sqlFilter += " and a.infoclass like '%," + newsClass + ",%'";
}
// 构建查询过滤语句-end ComList itera = new ComList();
String dbPagesArr[] = (new DbPages()).GetPageInfo(pageSize, page,
"select count(*) from TblNews a where a.status in (0,1) "
+ sqlFilter, "info_man.do?newsclass=" + newsClass
+ "&keywords=" + keywords + "&");
String PagesStr = dbPagesArr[2];
Integer.parseInt(dbPagesArr[0]);
itera = (new InfoList()).get(Integer.parseInt(dbPagesArr[0]),
pageSize, sqlFilter);
dbPagesArr = null;
if (itera.getParamlist() != null && itera.getParamlist().size() > 0) {
isdata = true; // 有数据
}
request.setAttribute("ComList", itera); if (isdata) { // 有数据
PagesInfo pagesinfo = new PagesInfo();
pagesinfo.setPageinfo(PagesStr);
request.setAttribute("PagesInfo", pagesinfo);
} else {
InfoTips infotips = new InfoTips();
infotips.setTipsInfo("No data");
request.setAttribute("InfoTips", infotips);
}
itera = null;
// 显示class列表
request.setAttribute("ClassList", new ClassList(newsClass));
request.setAttribute("CommonInfo", new CommonInfo(keywords));
return mapping.findForward("news/info_man");
}
}
info_mai.jsp的源代码如下:
<%@ page language="java" contentType="text/html; charset=GBK"%><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%><html:html locale="true">
<head>
<title>info center info manage</title>
<link href="../css/common.css" rel="stylesheet" type="text/css">
<script language="javascript">
function GoTodel(url){
   if(confirm('确认删除吗?')){
           listmsgs.action=url;
           listmsgs.submit();
   }
}
function ChangeMenu(newsclass){
    window.location="info_man.do?newsclass="+newsclass;
}
function selectall(v){
  var selectAllbul=false;
  var f = document.forms["listmsgs"];
  selectAllbul=document.listmsgs.idARR.checked;
  if(selectAllbul==true){
    if(confirm("确认全选吗?")){
       for (i=0;i<f.elements.length;i++)
          f.elements[i].checked = v;
    }else{
   document.listmsgs.idARR.checked=false;
}
  }else{
     for (i=0;i<f.elements.length;i++)
          f.elements[i].checked = v;
  }
}
</script>
</head><body>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td bgcolor="#FFFFFF">
信息中心&gt;信息管理
</td>
</tr>
<tr>
<td bgcolor="#cccccc">
&nbsp;
</td>
</tr>
</table>
<form name="cmdSearch" method="post" action="news/info_man.do">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td width="76%" height="30">
<select name="newsclass"
onChange="javascript:ChangeMenu(this.value);">
<option value="0">
全部类别
</option>
<logic:iterate name="ClassList" property="list" id="list">
<option value="<bean:write name="list" property="param0"/>"
<bean:write name="list" property="param2"/>>
<bean:write name="list" property="param1" />
</option>
</logic:iterate>
</select>
<logic:present name="CommonInfo" scope="request">
<input name="keywords" type="text"
value="<bean:write name="CommonInfo" property="info"/>">
</logic:present>
<input type="submit" name="cmdSearch" value="搜索>>">
</td>
<td align="right" width="24%" height="30">
<a href="info_add.do"><font color="#FF0000">添加信息</font>
</a>
</td>
</tr> </table>
</form>
<form name="listmsgs" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center"> <tr bgcolor="#CCCCCC">
<td width="7%" height="20" align="center" bgcolor="#CCCCCC">
<input type="checkbox" name="idARR" value="1"
onclick="javascript:selectall(this.checked);">
全选
</td>
<td width="68%" align="center" bgcolor="#CCCCCC">
信息标题
</td>
<td width="15%" align="center" bgcolor="#CCCCCC">
添加时间
</td>
<td width="5%" align="center" bgcolor="#CCCCCC">
状态
</td>
<td width="5%" align="center">
操作
</td>
</tr>
<logic:iterate name="ComList" property="paramlist" id="paramlist">
<tr bgcolor=<bean:write name="paramlist" property="param0"/>>
<td height="20" align="center">
<input type="checkbox" name="id"
value=<bean:write name="paramlist" property="param1"/>>
</td>
<td>
<bean:write name="paramlist" property="param2" />
</td>
<td align="center">
<bean:write name="paramlist" property="param3" />
</td>
<td align="center">
<bean:write name="paramlist" property="param4" />
</td>
<td align="center">
<a
href="info_edit.do?id=<bean:write name="paramlist" property="param1"/>&page=1"><font
color="#FF0000">编辑</font>
</a>
</td>
</tr>
</logic:iterate>
<logic:present name="PagesInfo" scope="request">
<tr bgcolor="#CCCCCC" align="center">
<td height="20">
<input type="button" name="cmdDel" value="删除"
onclick="javascript:GoTodel('info_del.do');">
</td>
<td colspan="4">
<bean:write name="PagesInfo" property="pageinfo" filter="false" />
</td>
</tr>
</logic:present>
<logic:present name="InfoTips" scope="request">
<tr>
<td height="20" colspan="5" align="center">
<bean:write name="InfoTips" property="tipsInfo" />
</td>
</tr>
</logic:present> </table>
</form>
</body>
</html:html> 访问该连接时出现如下的信息:
type Status reportmessage Invalid path /news/info_man was requesteddescription The requested resource (Invalid path /news/info_man was requested) is not available.我点击我的连接时显示的路径是http://localhost:8080/ioas/news/info_mai.do。但是就是出现上述错误。

解决方案 »

  1.   

    检查一下web.xml的配置对吗?Struts已经到2了
    不再需要编写ActionForm,不再需要继承Action.....如果是学习的话建议楼主看看Struts2吧
      

  2.   

    http://localhost:8080/ioas/news/info_mai.do。
    mai与man,拼写错误,一定是你拼写有错误,或者config.xml里拼写的错误
      

  3.   

    技术不在新与不新,在于实用与适用,客户要是有规定你能怎么办啊?
    举个例子,打项目能反复的用ajax吗?