我正在研究Fred Daoud的Stripes一书,并尝试将Hello World应用程序转换为使用友好URL,因为我不喜欢基于后缀的映射,例如http:// localhost:8080/getting_started/Hello.action.
这是之前...
的index.jsp:
<jsp:forward page="/Hello.action"/>
Run Code Online (Sandbox Code Playgroud)
web.xml中:
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
我的HelloActionBean上没有UrlBinding.我有书的例子.
我想知道这些书的例子是否适合早期版本的Stripes,因为我已经下载了1.5.1,我的web.xml定义了StripesFilter和StripesDispatcher,而我看到了其他地方使用过的DynamicMappingFilter,例如Fred的这篇文章在TheServerSide上.
无论如何,我做了以下更改:
的index.jsp:
<jsp:forward page="/hello"/>
Run Code Online (Sandbox Code Playgroud)
web.xml中:
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
HelloActionBean.java:
**@UrlBinding("/hello")**
public class HelloActionBean implements ActionBean
{
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试通过http:// localhost:8080/getting_started加载应用程序时,我看到:
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 …Run Code Online (Sandbox Code Playgroud)