访问webapp的项目
2019-04-16 11:10:54 Super_wolve 阅读数 384

如何访问webapp下的jsp和其他js文件

最近开始学习用idea编译工具编写代码,很喜欢它的黑色风格,然后在创建了一个springboot项目的时候发现了一个问题,那就是idea访问不到webapp里的jsp文件,这里写了几种可能会遇到的问题

  1. 先来看看application里的路径有没有写错

# 配置jsp文件的位置,默认位置为:src/main/webapp
spring.mvc.view.prefix=/
# 配置jsp文件的后缀
spring.mvc.view.suffix=.jsp
#配置返回jsp end
  1. 确定路径没有写错后我又看来了controller层的返回路径

这里确实没有写错
3. 然后上网找了很多办法都没有成功,后面发现了,idea和eclipse的搭建方式不同,所以创建的方式也不同。下面展示一下web搭建
4.
首先在main文件下创建一个新的目录文件webapp
在这里插入图片描述
5. 然后点击webapp这里,我是配置好的可以新建jsp文件,没有弄好配置的话这里是新建不了的在这里插入图片描述
6. 所以需要我们来进行设置
7. 点开工具栏上方的那个文件按钮
在这里插入图片描述
8. 点击Modules点击+号添加一个模板
在这里插入图片描述
10. 然后设置一下路径,就是你的项目路径path自己喜欢就行
在这里插入图片描述

  1. 重启项目现在就可以访问到了

还有一些其他的方法不过我的用不上可以考虑考虑看看
关于jsp页面访问不了

访问webapp的项目 相关内容

2018-04-13 19:31:52 mistyrain0109 阅读数 427

https://segmentfault.com/a/1190000013122831

子目录配置二级域名(备用):


<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <!--
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
               -->
    <!-- A "Connector" using the shared thread pool-->

    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO implementation. The default
         SSLImplementation will depend on the presence of the APR/native
         library and the useOpenSSL attribute of the
         AprLifecycleListener.
         Either JSSE or OpenSSL style configuration may be used regardless of
         the SSLImplementation selected. JSSE style configuration is used below.
    -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
    -->
    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
         This connector uses the APR/native implementation which always uses
         OpenSSL for TLS.
         Either JSSE or OpenSSL style configuration may be used. OpenSSL style
         configuration is used below.
    -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true" >
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        <SSLHostConfig>
            <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
                         certificateFile="conf/localhost-rsa-cert.pem"
                         certificateChainFile="conf/localhost-rsa-chain.pem"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>






         <Host name="localhost"  appBase="webapps"
        unpackWARs="true" 
        xmlValidation="false" xmlNamespaceAware="false">

         <Alias>localhost</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <Context path="" docBase="ocr"  ></Context>
      </Host>



        <Host name="域名"  appBase="webapps"
        unpackWARs="true" 
        xmlValidation="false" xmlNamespaceAware="false">

         <Alias>域名</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <Context path="" docBase="weixin"   ></Context>
      </Host>       
        <Host name="域名"  appBase="webapps"
        unpackWARs="true" 
        xmlValidation="false" xmlNamespaceAware="false">

         <Alias>域名</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <Context path="" docBase="workLoad"   ></Context>
      </Host>









    </Engine>
  </Service>
</Server>

访问webapp的项目 相关内容

2018-03-11 23:22:05 lizc_lizc 阅读数 8224

找到配置文件如下

conf/web.xml --> tomcat的Web配置文件

<init-param>

<param-name>listings</param-name>

<param-value>false</param-value>

</init-param>


value改成 true就行了!

<init-param>

<param-name>listings</param-name>

<param-value>true</param-value>

</init-param>

访问webapp的项目 相关内容

2019-04-04 07:53:38 gdsgdh308227363 阅读数 257

SpringBoot在启动其项目后,访问不到webapp下的内容
1.当我们用IntelliJ IDEA 启动 springBoot新项目访问webapp下的静态页面时出现404,且没有任何错误的情况下,但是用eclipse启动项目没有问题,解决方案:点击run-edit configurations 在Working directory 中选择 MODULEWORKINGDIR MODULE_WORKING_DIRMODULE WORKING DIR , 重新启动项目即可

第一步:

第二步:

重启项目访问即可。
 

访问webapp的项目 相关内容

2018-12-07 12:50:23 lrb893524 阅读数 144

1.tomcat原来的默认根目录是http://localhost:8080,如果想修改访问的根目录,可以这样:

找到tomcat的server.xml(在conf目录下),找到:
复制代码代码如下:

在前插入:

复制代码代码如下:

其中D:/eclipse3.3/jb51.net/tomcat/就是我想设置的网站根目录,然后重启tomcat。

再次访问http://localhost:8080时,就是直接访问D:/eclipse3.3/jb51.net/tomcat/目录下的文件了。

2.tomcat的web.xml(在conf目录下),在该文件中找到
复制代码代码如下:

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

这是tomcat默认的3个文件,当你输入指定路径后,tomcat会自动查找这3个页面。如果你想让tomcat自动找到自己的页面,比如main.jsp。可以修改上面信息为:
复制代码代码如下:

<welcome-file-list>
    <welcome-file>main.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

这样就可以了。

访问webapp的项目 相关内容

没有更多推荐了,返回首页