Error transferring JSP file to WEB-INF using Stripes

I have the following Stripes ActionBean:

package myapp;

import net.sourceforge.stripes.action.*;

public class WelcomeActionBean extends MyAppActionBean {
    @DefaultHandler
    public Resolution view() {
        return new ForwardResolution("/welcome.jsp");
    }
}

When I load /myapp/Welcome.action in a browser, the contents of welcome.jsp is displayed.

However, when I move welcome.jsp to / WEB -INF / jsp / welcome.jsp and change the ForwardResolution argument to reflect this change, that is:

return new ForwardResolution("/WEB-INF/jsp/welcome.jsp");

I get the following error when loading /myapp/Welcome.action:

net.sourceforge.stripes.exception.ActionBeanNotFoundException: Could not locate an ActionBean that is bound to the URL [/Welcome.action]. Commons reasons for this include mis-matched URLs and forgetting to implement ActionBean in your class. Registered ActionBeans are: {/controller/DefaultView.action=class net.sourceforge.stripes.controller.DefaultViewActionBean, /myapp/MyApp.action/=class myapp.MyAppActionBean, /myapp/Welcome.action/=class myapp.WelcomeActionBean, /controller/DefaultView.action/=class net.sourceforge.stripes.controller.DefaultViewActionBean, /myapp/MyApp.action=class myapp.MyAppActionBean, /myapp/Welcome.action=class myapp.WelcomeActionBean}
    net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:341)
    net.sourceforge.stripes.controller.NameBasedActionResolver.getActionBean(NameBasedActionResolver.java:264)
    net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:293)
    net.sourceforge.stripes.controller.DispatcherHelper$1.intercept(DispatcherHelper.java:106)
    net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
    net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
    net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
    net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
    net.sourceforge.stripes.controller.DispatcherHelper.resolveActionBean(DispatcherHelper.java:102)
    net.sourceforge.stripes.controller.DispatcherServlet.resolveActionBean(DispatcherServlet.java:238)
    net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:141)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)

Do I need to perform any special configuration to store JSP files in the WEB-INF directory?

+3
source share
2 answers

: WelcomeActionBean ([web, www, stripes, action]), NameBasedActionResolver ( javadoc), /myapp/Welcome.action ( ).

, /Welcome.action, ActionBean, URL-, /welcome.jsp ( , NameBasedActionResolver javadoc). JSP /WEB-INF/jsp, , , .

, :

  • URL- "" ( ), .. /myapp/Welcome.action

  • , , ActionBean /Welcome.action , , NameBasedActionResolver, action:

    package myapp.action;
    
    import net.sourceforge.stripes.action.*;
    
    public class WelcomeActionBean extends MyAppActionBean {
        @DefaultHandler
        public Resolution view() {
            return new ForwardResolution("/WEB-INF/jsp/welcome.jsp");
        }
    }
    
  • @UrlBinding , :

    package myapp;
    
    import net.sourceforge.stripes.action.*;
    
    @UrlBinding("/Welcome.action")
    public class WelcomeActionBean extends MyAppActionBean {
        @DefaultHandler
        public Resolution view() {
            return new ForwardResolution("/WEB-INF/jsp/welcome.jsp");
        }
    }
    
+4

WEB-INF - , . ( - , web.xml .class.)

JSP WEB-INF.

-1

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


All Articles