0

I have a class which send an email with activation link and the message is something like that :

String message =  "<html> <body><a href=\"http://localhost:8080/token?foo=abc\" >ACTIVE MY ACCOUNT</a> </body></html>";

On the other hand I have a controller

@Controller
@RequestMapping(value="/token",method = RequestMethod.GET)
public class RegisterController {
    public String active(@RequestParam("foo") String foo) {
       return foo;
   }
}

and I want foo to have abc value, but now when I click on activation link I got

Problem accessing /token.

Reason: Not Found

How can I modify this ?

3 Answers 3

1

Another alternative :

You access a resource with the url (your variable is in the uri)

@Controller
@RequestMapping(value="/token")
public class RegisterController {

    @RequestMapping(value = "/{foo}", method = RequestMethod.GET)
    public String active(@PathVariable String foo) {
       return foo;
   }
}

And

String message =  "<html> <body><a href=\"http://blockedcontent:8080/token/abc\" >ACTIVE MY ACCOUNT</a> </body></html>";
Sign up to request clarification or add additional context in comments.

Comments

1

I solved this in that way

@Controller
@RequestMapping("/register")
public class RegisterController {

@RequestMapping(value="/token", method= RequestMethod.GET)
public String active(
    @RequestParam("token") String token) {
    return token;

 }

}

and

String url =  "<html> <body><a href=\"http://localhost:8080/register/token?token=abc\" >ACTIVE MY ACCOUNT</a> </body></html>";

Comments

0

You are missing WebContentPath in the href link, which is Project Name if you didn't change it. So the href should be http://localhost:8080/ProjectName/token?foo=abc

By the way, the href should not be hard coded.

1 Comment

I have others controllers which works with something like that localhost:8080/something and I don't have to put project name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.