0

For example ,I want to create a 404 page with 2 different template ,one is pc,another is mobile.and I am using user-agent to calculate it.I am using * to match all url except the normal url my site own.

but it can only match like: www.abc.com/notfound1

it can not match www.abc.com/notfound1/notfound2,etc...

I want to match the url path controller not have,how to do it,thanks.

the point of view is below ,I want to using a word to describe it,and any means * symbol:

@RequestMapping(value = "any", method = RequestMethod.GET)

@RequestMapping(value = "any/any", method = RequestMethod.GET)

@RequestMapping(value = "any/any/any", method = RequestMethod.GET)

    @RequestMapping(value = "*", method = RequestMethod.GET)
public ModelAndView notfound() {

    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("error");
    String useragent = servletRequest.getHeader("user-agent");
    if (StringUtils.isNotBlank(useragent)) {
        boolean isMobile = CheckMobile.check(useragent);
        if (isMobile) {
            modelAndView.setViewName("errormobile");
        }
    }

    return modelAndView;
}

1 Answer 1

0

You can try: @RequestMapping(value={"/notfound1/notfound2", "/notfound3", "/notfound4"}) OR

You can control the view with JS depends on device resolution. Still i don't know what exactly you want to do.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.