Spring 这是春天的坏习惯吗
server.xmlSpring 这是春天的坏习惯吗,spring,tomcat,Spring,Tomcat,server.xml @Controller public class View implements InitializingBean { @GetMapping("log") public String log() { return "log"; } @Override public void afterPropertiesSet() throws Exception { System.out.println("in
@Controller
public class View implements InitializingBean {
@GetMapping("log")
public String log() {
return "log";
}
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("init");
}
}
当前,当启动时加载>=0的servlet启动失败时,上下文启动仍被视为正常。 对于一些webapp(比如基于spring的带有DispatcherServlet的webapp),这毫无意义:如果servlet启动失败,webapp将无法使用,让tomcat将上下文标记为失败会更明智
请参阅但上下文无法成功启动-你是什么意思?@mentalurg我的预期目标是curl将返回404,但结果是Servlet启动失败,上下文启动成功。@mentalurg所以JspServlet正常,curl xx.jsp正常。这是你的评论
<Host name="localhost" appBase="webapps"
autoDeploy="false" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">>
<Context crossContext="true" debug="5" docBase="/data/project/chenshun-tag-test/code" path="" reloadable="false">
</Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
➜ bin curl -I 127.0.0.1:18080/fix.jsp
HTTP/1.1 200
Set-Cookie: JSESSIONID=5223231CAB44739BEAEB0BDEA879649F; Path=/; HttpOnly
Content-Type: text/html;charset=ISO-8859-1
Transfer-Encoding: chunked
Date: Fri, 27 Dec 2019 14:08:59 GMT
➜ bin curl -I 127.0.0.1:18080/view/1.json
HTTP/1.1 500
Content-Type: text/html;charset=utf-8
Content-Language: zh-CN
Transfer-Encoding: chunked
Date: Fri, 27 Dec 2019 14:09:08 GMT
Connection: close