问题
I'm using Java EE for an enterprise application on Glassfish.
I have some xhtml files in WEB-INF to prevent direct URL access, that I can access using a servlet. I need to call a method of a managed bean when the user press a button.
The xhtml code I'm using is:
<h:form><p:commandButton action="#{managedBean.testFunction()}" value="Test function" type="submit" ajax="false" styleClass="block" /></h:form>
The problem is that the input of h:form seems to redirect me to the actual path to my xhtml file, e.g.:
My servlet mapped at:
/ServlerDispatcher/DispatcherServlet
using:
request.getRequestDispatcher("/WEB-INF/HiddenFiles/fileA.xhtml").forward(request, response);
displays the xhtml file in the WEB-INF folder, that contains the form I mentioned above. Submitting the form, by pressing the button redirects me to this URL:
/ServlerDispatcher/WEB-INF/HiddenFiles/fileA.xhtml``
that cannot be displayed since it's in the WEB-INF folder to prevent direct URL access.
As I said what I really need is execute a managed bean method when the user press a button. How can I do that?
Thanks for your attention
来源:https://stackoverflow.com/questions/28036049/use-of-hform-in-facelets-files-in-web-inf-opened-by-requestdispatcherforward