我的情况是 
   点击查看文章的Action namespace是article,(地址:http://localhost:8086/aoao/article/get.action)         跳转到A页面,在A页面文章下面有个发表评论的表单,namespace是comment,
   当我点击发表评论时候他的Action是 http://localhost:8086/aoao/article/comment/save.action 他把文章的namespace也带进来了,Comment的action就找不到了。
   这如何是好啊?

解决方案 »

  1.   


    加了命名空间啊···
    http://localhost:8086/aoao/article/comment/save.action不然地址也不会带上comment
      

  2.   

    楼主在jsp页面设置一下basepath吧,可以解决这个问题。。
      

  3.   

    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><base href="<%=basePath%>"> 
      

  4.   


    所有链接都用了basePath,如果不用basePath我的地址访问一次就会加上一个namespace,
      

  5.   

    <%@ page language="java" pageEncoding="utf-8"%>
    <%@ include file="/WEB-INF/jsp/common.jsp"%>
    <html>
    <head>
    <body>
    <div id="comage">
    <jsp:include page="header.jsp" />
    <div id="content"> <span>${article.title} </span>
    <br />
    <span><s:date name="createDate" format="yyy-MM-dd hh:mm:ss" />
    </span>
    <div class="divcontent">
    ${article.content}
    </div>
    <hr>
    <!--  评论 -->
    <div class="imagespinlun">
    <h1>
    评论
    </h1>
    <s:form action="save" namespace="comment" theme="simple">
    <div class="neirong">
    <span class="capt">昵称:</span>
    <s:textfield name="comment.guestName" />
    <p />
    <s:textarea name="comment.content" cols="60" rows="5" />
    <input type="hidden" name="comment.articleId" value="${article.id}">
    </div>
    <div>
    <s:submit value="发表" />
    </div>
    </s:form>
    </div>
    <!--  评论 end -->
    </div>
    <jsp:include page="category_list.jsp" />
    <jsp:include page="footer.jsp" />
    </div>
    </body>
    </html>
      

  6.   

    目前问题是当我点击发表评论时候他的Action是 http://localhost:8086/aoao/article/comment/save.action 他把文章的namespace也带进来了,发表评论Comment的action 找不到了。
      

  7.   

    在A页面没有看到bathpath,

    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><base href="<%=basePath%>">加到A页面试试吧。。
      

  8.   


    <%@ include file="/WEB-INF/jsp/common.jsp"%>
    我在这个页面引用了basePath 
      

  9.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <%@ taglib prefix="p" uri="/WEB-INF/tld/pager-taglib.tld"%>
    <% String path = request.getContextPath();
       String webPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    request.setAttribute("webPath", webPath);
    %>
      

  10.   

    你没有
    <base href="<%=basePath%>">
     request.setAttribute("webPath", webPath); //你在这一块,没必要把bathpath改成webPath,既然你改成了webPath,那么在设置base时要用:
    <base href="<%=webPath%>">