简体   繁体   English

键入spring应用程序的根链接后,tomcat会做什么?

[英]What will tomcat do after I type the root link of a spring application?

Let's say I have an application written with spring framework, and I want to know, when I typed in : 假设我有一个使用spring框架编写的应用程序,当我输入以下内容时,我想知道:
http://localhost:8080/test http:// localhost:8080 / test
link, what tomcat will do to generate response for this request ? 链接,tomcat将如何生成对此请求的响应?
Should it have to pass all filters first, then ???? 应该首先通过所有过滤器吗?

And after I typed in the url, it always be directed to another link like http://localhost:8080/test/login , where was this redirection implemented ? 在输入url之后,它总是被定向到另一个链接,例如http:// localhost:8080 / test / login ,此重定向在哪里实现的?

If it is hard to explain to me, then please recommend me a book for that, thanks very much ! 如果很难向我解释,请为此向我推荐一本书,非常感谢!

what tomcat will do to generate response for this request ? tomcat将如何对此请求生成响应?

Tomcat will typically send the the request to the relevant DispatcherServlet instance, as configured in your "web.xml" file. Tomcat通常会将请求发送到相关的DispatcherServlet实例,该实例在“ web.xml”文件中进行了配置。 This is described in the Spring documentation . Spring文档中对此进行了描述。

Should it have to pass all filters first, then ???? 应该首先通过所有过滤器吗?

Yes. 是。 Filters are applied before (and after) requests are passed to the Servlet. 在将请求传递到Servlet之前(和之后)应用过滤器。

And after I typed in the url, it always be directed to another link like http://localhost:8080/test/login , where was this redirection implemented ? 在输入url之后,它总是被定向到另一个链接,例如http:// localhost:8080 / test / login ,此重定向在哪里实现的?

That depends on how you have implemented security. 这取决于您如何实现安全性。 It could be done at the Tomcat level (I think), using SpringSecurity, or hard-wired logic in your Spring MVC controller, or in a plain (non-Spring) Servlet, Filter or (Tomcat specific) Valve. 可以在Tomcat级别(我认为),使用SpringSecurity或在Spring MVC控制器中或在普通(非Spring)Servlet,Filter或(特定于Tomcat的)Valve中使用硬连线逻辑来完成。

If you are looking for advice on the best way to implement login / security, I'd recommend using SpringSecurity. 如果您正在寻找实现登录/安全性最佳方法的建议,我建议使用SpringSecurity。 SpringSecurity works using Filters. SpringSecurity使用过滤器工作。

If it is hard to explain to me, then please recommend me a book for that, thanks very much ! 如果很难向我解释,请为此向我推荐一本书,非常感谢!

The online Spring and SpringSecurity documentation is as good a place as any. 在线SpringSpringSecurity文档非常适合任何地方。 This documentation tends not to spell out exactly how requests get processed in the context of a particular web container, but you should be able to figure the details from the Tomcat docs and the Servlet specification. 本文档往往不会确切说明在特定Web容器的上下文中如何处理请求,但是您应该能够从Tomcat文档和Servlet规范中找到详细信息。

If there's a controller that's mapped to that URL, the Spring DispatcherServlet will send the request to it for handling. 如果有一个映射到该URL的控制器,Spring DispatcherServlet将向其发送请求以进行处理。

If the controller determines that the next view ought to be the one that corresponds to /test/login, then it'll specify so when it sets the ModelAndView. 如果控制器确定下一个视图应该是对应于/ test / login的视图,则它将在设置ModelAndView时指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring MVC作为Tomcat 6中的ROOT应用程序 - Spring MVC as ROOT Application in Tomcat 6 如何将Tomcat嵌入到Spring Framework MVC应用程序中? - How do I embed Tomcat in a Spring Framework MVC application? 如何在没有嵌入式tomcat的情况下启动Spring Boot应用程序? - How do I launch a Spring Boot application without the embedded tomcat? 如何修改文件Root of Spring boot2嵌入式tomcat - How do I modify the document Root of Spring boot2 embedded tomcat 在INFOS之后Tomcat不继续:在迁移到Spring 3.2.3.RELEASE之后初始化Spring root WebApplicationContext - Tomcat doesn't proceed after INFOS: Initializing Spring root WebApplicationContext after migration to Spring 3.2.3.RELEASE 如何将 Tomcat 重写阀添加到 Spring Boot 2.0 应用程序 - How do I add Tomcat rewrite valve to Spring Boot 2.0 application 如何为部署到tomcat 6的Spring Boot应用程序添加外部属性文件位置? - How do I add external property file location to Spring Boot application deployed to tomcat 6? 更新后如何强制 tomcat Web 应用程序重新加载信任库 - How do I force a tomcat web application reload the trust store after I update it Spring如何启用Tomcat阀门 - How do I Spring enable a Tomcat valve Maven,春天,tomcat7:要正确部署,我需要在pom.xml中做什么? - Maven, spring, tomcat7: What do I need in pom.xml to deploy correctly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM