在我原来的电脑上面有一个项目,在tomcat的webapps里面,因为和域名绑定了,我就在tomcat的server.xml里面配置了如下内容:<Host name="www.ceshi.com"  appBase=""
  unpackWARs="true" autoDeploy="true"
  xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="D:\Tomcat 6.0\webapps\ceshi" reloadable="true" crossContext="true"/>
 </Host>这样以后访问这个域名的时候就可以自动的访问到我的这个项目,可以我不能运行起来我本机webapps里面的别的项目了:
为什么啊?
就是当我敲:
http://localhost:8080/manage/login.jsp
的时候不能访问了,然后我就配置了一下server.xml,如下:<Host name="xyh.hbu.cn"  appBase=""
  unpackWARs="true" autoDeploy="true"
  xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="D:\Tomcat 6.0\webapps\hbuxyh" reloadable="true" crossContext="true"/>
 </Host><Host name="localhost"  appBase=""
  unpackWARs="true" autoDeploy="true"
  xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="D:\Tomcat 6.0\webapps\manage" reloadable="true" crossContext="true"/>
 </Host>这样以后我用http://localhost/login.jsp这个地址就直接可以访问了,但是我敲击本机的ip的时候访问不了,同时外网内网都不能访问?
问一下高手,怎么做才能让我的后来的那个项目放在服务器上,并且运行起来?

解决方案 »

  1.   

    你后面一个不加name不就行了?话说...
      

  2.   

    我尝试了,还是不行。我与此同时也配置了C:\WINDOWS\system32\drivers\etc的hosts下面设置了两个本机的ip指向,有影响吗?
      

  3.   

    可以更改tomcat下conf下的web.xml
    找到<welcome-file-list>
    <welcome-file>index.html</welcome-file>
            <welcome-file>index.htm</welcome-file>     
            <welcome-file>index.jsp</welcome-file>  
        </welcome-file-list>
    改成    <welcome-file-list>
     <welcome-file>index.jsp</welcome-file>
            <welcome-file>index.html</welcome-file>
            <welcome-file>index.htm</welcome-file>       
        </welcome-file-list>
    再修改webapps\ROOT的inde.jsp中资料或把inde.jsp里的内容清空掉,
    再加几段代码,定向指向某页面就ok了!
    比如
    <%if(request.getRequestURL().indexOf("stellafootwear.com.cn") > 1) {
    response.sendRedirect("/typ/index.jsp");
    }else{
    response.sendRedirect("/tips/login.jsp");
    }
    %>
      

  4.   

    <Host name="xyh.hbu.cn"  appBase=""
      unpackWARs="true" autoDeploy="true"
      xmlValidation="false" xmlNamespaceAware="false">
    <Context path="/" docBase="D:\Tomcat 6.0\webapps\hbuxyh" reloadable="true" crossContext="true"/>
     </Host>
    <Host name="my.oschina.net" debug="0" appBase="D:\Tomcat50\webapps\my.oschina.net">
          <Context path="" docBase="." debug="0"/>
    </Host>
    这两种配置虚拟主机的方法有什么不同啊,表达的结果是什么样子的呢/
      

  5.   

    http://www.oschina.net/code/snippet_12_2034
    http://apps.hi.baidu.com/share/detail/9249830
    给2篇文章你参考下希望对你有用。
      

  6.   

    127.0.0.1       localhost hosts里的映射应该用ip可以访问的
      

  7.   

    不知道能不能配置2个 Host 
      

  8.   

    是啊
    我觉得我配置成:
    127.0.0.1       localhost
    127.0.0.1       bhu.cn
    这样的情况,一个是域名,一个是localhost,可以用ip对我的项目进行访问啊,可是实际则不然;
    难道是我的第一个项目是用jeecms做的有影响?
      

  9.   

    请高手过来帮帮忙吧,我原来以为csdn是很厉害的论坛,但是现在看看,这个一个问题都没有一个满意的答案,哎