<form action="/website/forum.action" method="post">
是不是也可以用<form action="forum.action" method="post">website是我的工程名

解决方案 »

  1.   

    /就到website项目根了,不要website啊
      

  2.   

    你理解错了,website不是工程名,是eclipse给你设置的web-context
    自己可以修改,所以你要改成你那种形式应该是不可能得。
      

  3.   

    这个要看你的url是上面样的了。
      

  4.   

    可以。
    只要JSP和action在同级,如:
    jsp在web根目录下
    而action正好是/forum.action。如果级别不一样,用..找上层路径,用/找下层路径。
      

  5.   

    http://code.google.com/p/simplejee/source/browse/trunk/simplejee/WebContent/html/examples/path.html看看这个或许有点用处
      

  6.   

    lz说的第二种好像这样比较保险<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    //这里要加上
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
    //这里要加上
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
      </head>
      
      <body>
          </body>
    </html>
      

  7.   

    <form action="${pageContext.request.contextPath}/forum.action" method="post">
      

  8.   

    如果是struts2的话,就用标签啊,就不用管路径了,它会自动补上去<%@ taglib prefix="s" uri="/struts-tags" %>
    ...<s:form action="forum">
    ....
    </s:form>
      

  9.   


    不用这么麻烦啊  <%=request.getContentPath() %>/form.action完事
      

  10.   

    这个路径貌似是不行的, LZ输出看看吧?没有不是我们常见的localhost:8080/appName