无论是超链无论是表单提交路径都不出现工程名,怎么解决啊?

解决方案 »

  1.   

    你的web应用root的地址:
    jsp中 ${pageContext.request.contextPath}
    java中 request.getContextPath()
      

  2.   

    我们公司的:
    程序员的做法一般是把工程名放在变量里,如最经典的万能的request.getContextPath()
    而美工的一般做法是把工程名取得巨复杂无比,需要改工程名的时候来一个全局替换。
      

  3.   


    jsp中 ${pageContext.request.contextPath} 
    java中 request.getContextPath()这样调用就可以不用写工程名了
      

  4.   

    不是的,人家要求我路径是要直接写servlet的包,而不出现任何东西
      

  5.   


    难道你需要的是把工程项目放到tomcat的webapps\root\下?
      

  6.   

    什么意思啊,是要配置tomcat的文件,还是把项目放进去啊?不懂这些
      

  7.   

    要设置虚拟路径举个例子来说:比如我输入www.baidu.com访问的是我自己的工程,是这意思吧要在配置文件中改
      

  8.   

    LZ应该是说在代码里怎样避免包含项目上下文
    用request.getContextPath()
      

  9.   


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

  10.   


    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
    <%
    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 'MyJsp.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>
        This is my JSP page. <br>
      </body>
    </html>
      

  11.   

    你要是用tomcat的话,把你的工程名运行时为ROOT,就是webapps下面的那个, 我们做的项目都是的,所有代码和JSP都在ROOT里,访问就变成http://localhost:8080