Clicking h:commandLink causes Uncaught ReferenceError: mojarra is not defined

前端 未结 2 1475
终归单人心
终归单人心 2020-12-03 18:56

I am aware of this post and I double checked all the possibilities there.

I\'m using JSF 2.0 with Mojarra implementation on Glassfish 3.

I\'m trying

2条回答
  •  無奈伤痛
    2020-12-03 19:22

    The source and generated HTML output looks fine, you have there a in the JSF source (otherwise JSF wasn't able to auto-include any CSS/JS files), and the javax.faces:jsf.js script is present in the HTML output.

    You said, you got a JS error that mojarra is not definied. That can only mean that the following auto-generated script

    
    

    did not result in a valid response. That can in turn only mean that you've a Filter which is mapped on /* or *.xhtml which is restricting the jsf.js resource request in some way. Perhaps some homegrown authentication filter which is not doing its job entirely right. Try opening

    http://localhost:8080/maze/javax.faces.resource/jsf.js.xhtml?ln=javax.faces

    in your browser to see what it actually retrieved (or use the web developer tools to check the response). If it's indeed not the proper response and the problem is indeed in the Filter, then you probably need to rewrite it as such that it should continue the chain when the request URI starts with ResourceHandler.RESOURCE_IDENTIFIER.

    E.g.

    HttpServletRequest req = (HttpServletRequest) request;
    
    if (req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) {
        chain.doFilter(request, response); // Let it continue.
        return;
    }
    

提交回复
热议问题