简体   繁体   English

正则表达式Struts 1.3操作映射

[英]Regular Expressions Struts 1.3 Action Mapping

I am working on a project using Struts 1.3 from what I can tell, given that this is at the top of the struts-config-default.xml file: 我正在使用Struts 1.3开发一个项目,因为它位于struts-config-default.xml文件的顶部:

<!DOCTYPE struts-config PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
    "http://struts.apache.org/dtds/struts-config_1_3.dtd">

Is there any way to go about mapping a wildcard for an action forward to a jsp file? 有什么方法可以将操作的通配符映射到jsp文件? I have tried all sorts of wildcard variations: 我尝试了各种通配符变体:

<action path="/hello/candy" type="com.officedepot.globalweb.framework.action.ForwardDisplayAction">
        <forward name="success" path="/WEB-INF/jsp/candyStore.jsp" />
    </action>

I have a single page application that gets loaded in the 'candyStore.jsp' so i would like all and any URIs after /hello/candy to route to the same JSP. 我有一个单页应用程序已加载到“ candyStore.jsp”中,因此我希望/ hello / candy之后的所有和所有URI都路由到同一JSP。 (eg. www.site.com/hello/candy/pageOne, www.site.com/hello/candy/33/jellybean, www.site.com/hello/candy/test all should forward to the jsp candyStore) (例如,www.site.com / hello / candy / pageOne,www.site.com / hello / candy / 33 / jellybean,www.site.com / hello / candy / test都应转发到jsp candyStore)

Is this at all possible using Struts 1.3 or should I be writing all the possible routes :( 使用Struts 1.3完全可行吗?还是我应该编写所有可能的路线:(

Thanks! 谢谢!

In your action file 在您的操作文件中

public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request , HttpServletResponse response) 
            throws Exception{


        //Perform any code here like error 404.
        return mapping.findForward("unspecified");
    }

In your struts action path in config file 在配置文件中的struts操作路径中

<forward name="unspecified" path="/candyStore.jsp"/>

About 30 seconds on Google: 在Google上大约30秒:

https://dzone.com/tutorials/java/struts/struts-example/struts-wildcards-in-action-mapping-example.html https://dzone.com/tutorials/java/struts/struts-example/struts-wildcards-in-action-mapping-example.html

<action-mappings>
  <action path="/*Action" type="com.vaannila.reports.{1}Action" name="{1}Form">
    <forward name="success" path="/{1}.jsp" />
  </action>
</action-mappings>

You would not require the wildcard in the forward's path . 您将不需要在转发path使用通配符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM