Top community members
All Wiki Articles Create Wiki Article

Many years me and my friends we were volunteers on my university doing programming classes for young people.

I got main conclusion: Young people are awesome, especially students, because they always bring new and fresh ideas :)
* I loved to do it but my time is limited

  I decided to create something that will help millions of students

Now I am here

co-founder

Java - spring page URL redirection

0 contributions
6 points

In Spring Freamwork it is possible to make url redirection in following way.

1. redirection:my_url prefix example

RedirectionExampleController.java file:

package com.example;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RedirectionExampleController {

    @RequestMapping(value = "/redirect-to-my-final-page", 
        method = RequestMethod.GET)
    public String redirectToMyFinalPage() {
        return "redirect:/my-final-page";
    }

    @RequestMapping(value = "/my-final-page", 
        method = RequestMethod.GET)
    @ResponseBody
    public String myFinalPage() {
        return "This is my final page.";
    }
}

 Running:

  1. Run server, e.g. on localhost:8080
  2. Open in browser following link: http://localhost:8080/redirect-to-my-final-page

Result:

Note: web page should be redirected to http://localhost:8080/my-final-page.

2. References

  1. Redirecting - Spring Docs 

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more