Struts uses the FORM tag in the page

xiaoxiao2021-03-06  55

Struts uses the FORM tag in the page

The Struts's Form tag defines a page of a page, but the Struts tag requires the action maping in Module Config according to the value of the action, and initializes the Action Form according to the value of an action mapping. Therefore, a Module Config is required in the Form mark. Here, getting which module config has become the key to the Form tag, if the Module Config is incorrect, will cause the corresponding action mapping to find or find but not the correct action mapping. Thereby causing errors for Cannot Retrieve Mapping for {Action Name} or other unexpected errors. In the FORM tag, the process contains the search module, its lookup method is first getting the current module config from the request, if not found, get the default module config from servlet context (ie Module Prefix "" Module).

We analyze the initialization of ActionServlet, you can find that ActionServlet saves the initialized module config in the properties of Servlet Context, where the property name is Globals.Module_Key Prefix, how is the current module config of the Request object? It is an ActionServlet that matches the URL of the request with the requested URL and saved in the servlet context. If the match is successful, the attribute name is "the prefix" MODULE CONFIG that matches the successful prefix as the current Module config returns, the process appears in the actionServlet's Process method, when select module, will select the current module config, and save the property globals.Module_Key in the Request's property. And forward the example to the RequestProcessor object.

From the above analysis, we can see the JSP page containing the Form TAG. If you want to correctly associate into a module, you need to put the current Module Config object in the Request request in advance, but store Module Config to the Request request. The action is done in the ActionServlet. Therefore, the page only after processing an ACTON (during processing the action, the current module is pressed according to the URL of the Action, and saves it in the request), and heavy by redirect = false Oriented to a JSP page to enable the JSP page to be correctly associated into module, otherwise it will be associated with the default module config, and all JSP files are associated with the URL of the JSP directly in the address bar. To the default module config.

转载请注明原文地址:https://www.9cbs.com/read-116986.html

New Post(0)