Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize springMVC Route Jump

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to achieve springMVC routing jump". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Achieve your goal: using the springMVC front-end controller, jump to the front-end page under WEB-INF 's templates.

Illustration

1. Directory structure

two。 Create a webapp project for maven. Remember to delete the index.jsp file after it is created. Otherwise, we will skip to this file first. We will use the front-end controller to forward all requests.

3. In xml, configure springMVC front-end controller

Archetype Created Web Application springMVC org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:springMVC.xml 1 springMVC /

4. Create and configure springMVC.xml. Remember to configure context (required to enable scanning)

5. Matching path

@ Controllerpublic class HelloController {/ / "/"-> / web-inf/templates/index.html / / RequestMapping request mapping / / value can not write @ RequestMapping (value= "/") public String tindex () {/ / return the view name, because we have configured the suffix in the view parser, so there is no need to write return "index" here. } @ RequestMapping (value= "/ target") public String toTarget () {return "target";}}

Index.html

/ access the target ahh

Target.html

This is the end of TitleHELLOWORLD's "how to achieve springMVC Route Jump". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 277

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report