친숙한 URL을 사용하도록 줄무늬 응용 프로그램을 변환합니다

StackOverflow https://stackoverflow.com/questions/725534

  •  05-09-2019
  •  | 
  •  

문제

나는 Fred Daoud의 Stripes Book을 통해 일하고 있으며 Hello World 애플리케이션을 변환하여 친절한 URL을 사용하도록 노력하고 있습니다. http : // localhost : 8080/gettarted/hello.action.

여기에 ...

index.jsp :

<jsp:forward page="/Hello.action"/>

web.xml :

<servlet-mapping>
    <servlet-name>DispatcherServlet</servlet-name>
    <url-pattern>*.action</url-pattern>
</servlet-mapping>

그리고 나는 내 HelloActionBean에 urlbinding이 없습니다. 책 예제가 작동합니다.

1.5.1을 다운로드했으며 Web.xml이 Stripesfilter 및 Stripesdispatcher를 정의하는 반면, 다른 곳에서 사용되는 DynamicmappingFilter를 보았을 때 책 예제가 이전 버전의 줄무늬에 적합 할 수 있는지 궁금합니다. 이 기사 TheServerside의 Fred에 의해.

어쨌든, 나는 다음과 같은 변경을했다.

index.jsp :

<jsp:forward page="/hello"/>

web.xml :

<servlet-mapping>
    <servlet-name>DispatcherServlet</servlet-name>
    <url-pattern>/*</url-pattern>
 </servlet-mapping>

helloactionbean.java :

**@UrlBinding("/hello")**
public class HelloActionBean implements ActionBean 
{

그러나 앱을로드하려고 할 때 http : // localhost : 8080/gettarted 나는 이것을 본다 :

net.sourceforge.stripes.exception.ActionBeanNotFoundException: Could not locate an ActionBean that is bound to the URL [/]. Commons reasons for this include mis-matched URLs and forgetting to implement ActionBean in your class. Registered ActionBeans are: {/hello=class stripesbook.action.HelloActionBean, /controller/DefaultView.action=class net.sourceforge.stripes.controller.DefaultViewActionBean, /hello/=class stripesbook.action.HelloActionBean, /controller/DefaultView.action/=class net.sourceforge.stripes.controller.DefaultViewActionBean}
    at net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:341)

그리고 내가 그것을 통해 접근한다면 http : // localhost : 8080/gettarted/hello 서버는 한 번의 예외를 던지는 루프로 들어가는 것 같습니다.

감사합니다 - 감사합니다.

도움이 되었습니까?

해결책

나는 몇 가지 다른 일을 시도하고 그것을 작동 시켰습니다 ...

web.xml에서 기존 Dispatcherservlet Servlet 및 Servlet 매핑 정의를 제거하고 DynamicMappingFilter로 교체했습니다.

보너스로, 링크 이벤트가 통과되는 방식을 변경하려면

http://localhost:8080/getting_started/hello?randomDate=

becomes

http://localhost:8080/getting_started/hello/randomDate

ActionBean의 Urlbinding을 다음으로 변경하십시오.

@UrlBinding("/hello/{$event}")

다른 팁

Dispatcher Servlet을 DynamicMappingFilter로 바꾸는 것은 효과가 없었습니다 (DynamicMappingFilter에 대한 오류 메시지가 StripesFilter와 함께 작동합니다). 따라서 Web.xml에 두 개의 필터와 하나의 필터 매핑이 구성되어 있습니다.

<filter>
    <display-name>Stripes Filter</display-name>
    <filter-name>StripesFilter</filter-name>
    <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
    <init-param>
        <param-name>ActionResolver.Packages</param-name>
        <param-value>com.package.myactions.package</param-value>
    </init-param>
</filter>

<filter>
    <description>Dynamically maps URLs to ActionBeans.</description>
    <display-name>Stripes Dynamic Mapping Filter</display-name>
    <filter-name>DynamicMappingFilter</filter-name>
    <filter-class>
        net.sourceforge.stripes.controller.DynamicMappingFilter
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>DynamicMappingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top