How to return to the same page after processing on the server side?

Thinking that in struts 1.2 we say that the function public ActionForward abc () {return null;} will return to the same page. But I got this exception. java.lang.NullPointerException org.apache.struts.action.RequestProcessor.processForwardConfig (RequestProcessor.java:441) org.apache.struts.action.RequestProcessor.process (RequestProcessor.java:279) org.apache.struts.action.ActionServlet .process (ActionServlet.java:1482) org.apache.struts.action.ActionServlet.doPost (ActionServlet.javahaps25) javax.servlet.http.HttpServlet.service (HttpServlet.java:710) javax.servlet.http.HttpServlet .service (HttpServlet.java:803) org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter (UrlRewriteFilter.java:738)

How to get to the same page?

+3
source share
2 answers

In struts-config.xml write the forward tag inside your action tag like this.

<action ...>
<forward name = "samePage" path="..."/>
</action>

Now in your code use

mapping.findForward("samePage");
+2
source

you can use

return mapping.getInputForward();
+1
source

Source: https://habr.com/ru/post/1746339/


All Articles