zoukankan      html  css  js  c++  java
  • 设置tomcat默认访问的项目

    正常访问tomcat发布的项目,需要在url后面加上项目名,如果想不加项目名直接通过ip访问,可以修改配置文件实现

    1、直接将你的变异后的项目文件,复制到tomcat的webapps/ROOT 目录下面,可以理解成把你的项目名字部署的时候改成ROOT,这样不需要修改配置就可实现不输入项目名访问

    2、修改配置文件,修改conf/server.xml,找到<Host 标签,在标签内增加 <Context path="" docBase="superquery" reloadable="true" /> 

          其中docBase指向webapps中你项目的名称

    如果不想通过8080端口直接通过ip地址就能访问,可以修改tomcat端口为80,在conf/server.xml中找到下面这里,将8080改成80即可

     重启后就可以直接通过ip地址访问了,不需要再输端口和项目名称

    另外我还遇到个问题,tomcat日志中打印org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header的错误

    20-Apr-2020 22:16:19.456 INFO [http-nio-80-exec-6] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
     Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
        java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
            at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:483)
            at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684)
            at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
            at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
            at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
            at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
            at java.lang.Thread.run(Thread.java:748)

    修改conf/catalina.properties文件,最后一行增加tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

    再重启tomcat,就没有再报错了

    还遇到个用 /var/lib/tomcat-7.0-bsp/bin/catalina.sh start; 命令启动的时候报错,Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

    At least one of these environment variable is needed to run this program

    在catalina.sh文件的开头添加JAVA_HOME的环境变量后不报错了

    export JAVA_HOME=/var/lib/jdk1.8.0_221
  • 相关阅读:
    Educational Codeforces Round 83 --- F. AND Segments
    Educational Codeforces Round 83 --- G. Autocompletion
    SEERC 2019 A.Max or Min
    2019-2020 ICPC Southwestern European Regional Programming Contest(Gym 102501)
    Educational Codeforces Round 78 --- F. Cards
    今天我学习了一门全新的语言
    codeforces 1323D 题解(数学)
    Educational Codeforces Round 80 (Div. 2) 题解 1288A 1288B 1288C 1288D 1288E
    Educational Codeforces Round 81 (Div. 2) 题解 1295A 1295B 1295C 1295D 1295E 1295F
    Codeforces Round #617 (Div. 3) 题解 1296C 1296D 1296E 1296F
  • 原文地址:https://www.cnblogs.com/yanh0606/p/12737789.html
Copyright © 2011-2022 走看看