jte icon indicating copy to clipboard operation
jte copied to clipboard

Spring Security Login ViewResolver

Open humanry opened this issue 1 year ago • 4 comments

When integrating with Spring Security the view is not found, for non-secured pages the view works fine but for a page configured as login page in spring security, i get an error like so

`ERROR 10500 --- [admin] [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause

jakarta.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)`

humanry avatar Oct 16 '24 07:10 humanry

@humanry Do you have an example repo? Do you have a custom login page (with jte) or want to use the default one?

atomfrede avatar Oct 21 '24 08:10 atomfrede

The view name should not include a forward slash; instead, change it to "login".

Alwan avatar Nov 25 '24 17:11 Alwan

Usually in Spring the view name can start with a forward slash. Maybe it would be nice to enable this with JTE too.

This does NOT work:

public class GreetingController {
    public static final String PATH = "/greeting";
    @GetMapping(PATH)
    public String greeting() {
        return PATH; 
    }
}

But this works:

public class GreetingController {
    public static final String PATH = "/greeting";
    @GetMapping(PATH)
    public void greeting() {
    }
}

the implied viewName is "/greeting" but Spring removes the forward slash, I guess, before JTE can resolve the name

kicktipp avatar Jun 04 '25 07:06 kicktipp

As the default template location is src/main/jte (and suffix is .jte) it would make perfectly sense to add a slash at the beginning of your viewname like /greeting, combined it would be src/main/jte/greeting.jte

kicktipp avatar Jun 04 '25 07:06 kicktipp