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 implement controller Interface Jump to another controller Interface

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to achieve controller interface jump to another controller interface, the article is very detailed, has a certain reference value, interested friends must read it!

The controller interface jumps to another controller interface @ RestController@RequestMapping ("/ aaa") public class TestController {@ RequestMapping ("/ test1") public ModelAndView test1 (HttpServletResponse response) {ModelAndView view = new ModelAndView (); view.setViewName ("redirect:/aaa/test2"); / / try {/ / response.sendRedirect ("/ test2") / /} catch (IOException e) {/ / e.printStackTrace (); / /} return view;} @ RequestMapping ("/ test2") public ModelAndView test2 () {System.out.println ("this is test2");}} method problem of calling another Controller in Controller

1. Cannot be called directly as a class

2. You can pass it to another Controller class and run it through url forwarding.

3. The service injected into Controller will report a null value if it is directly used as an instance variable.

4. Note that the Controller layer does not deal with complicated logic, and the logic should be handed over to the Service layer.

5. Static resource mapping, that is, static resource release. When the front-end controller intercepts "/", static resources such as .js, .jpg, .css need to be released.

6. / *, it will cause jsp,js,jpg. Are intercepted, can not be executed, generally do not use

The above is all the content of the article "how to implement the controller interface to jump to another controller interface". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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: 0

*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