Error when add custom controller to Broadleaf

101 Views Asked by At

I follow below tutorial for add custom controller to broadleaf admin console.

https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/admin/admin-custom-controllers

Then I update my code as mentioned below. Because I'm getting some updates from below links.

http://forum.broadleafcommerce.org/viewtopic.php?t=4209

Broadleaf add custom field in navigation side bar

Controller:

@Controller
@RequestMapping("/" + MyController.SECTION_KEY)
@Secured("ROLE_PERMISSION_OTHER_DEFAULT")
public class MyController extends AdminAbstractController {

    protected static final String SECTION_KEY = "test";

    @RequestMapping(value = "", method = RequestMethod.GET)
    public String test(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
        // This is expected by the modules/emptyContainer template, this is a custom template that gets included into the body
        model.addAttribute("viewType", "test");

        // ensure navigation gets set up correctly
        setModelAttributes(model, SECTION_KEY);

        // gets the scaffolding set up to display the template from the customView attribute above
        return "modules/defaultContainer";
    }

}

Add UI page in below path.

enter image description here

After run the /test every time I got the below error message.

2020-07-13 12:08:24.923 ERROR 17577 --- [nio-8081-exec-9] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8081-exec-9] Exception processing template "layout/fullPageLayout": Error resolving template "views/test", template might not exist or might not be accessible by any of the configured Template Resolvers (template: "modules/defaultContainer" - line 7, col 15)

Could you please help me to solve this issue. Any help or workarounds can be really appreciated.

0

There are 0 best solutions below