簡體   English   中英

正則表達式Struts 1.3操作映射

[英]Regular Expressions Struts 1.3 Action Mapping

我正在使用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">

有什么方法可以將操作的通配符映射到jsp文件? 我嘗試了各種通配符變體:

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

我有一個單頁應用程序已加載到“ candyStore.jsp”中,因此我希望/ hello / candy之后的所有和所有URI都路由到同一JSP。 (例如,www.site.com / hello / candy / pageOne,www.site.com / hello / candy / 33 / jellybean,www.site.com / hello / candy / test都應轉發到jsp candyStore)

使用Struts 1.3完全可行嗎?還是我應該編寫所有可能的路線:(

謝謝!

在您的操作文件中

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


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

在配置文件中的struts操作路徑中

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

在Google上大約30秒:

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>

您將不需要在轉發path使用通配符。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM