struts2与freeer结合开发struts.xml的配置文件为:
<action name="*">
            <result type="freeer">/WEB-INF/ftl/{1}.ftl</result>
        </action>
struts.properties的配置文件为:
struts.ui.theme=simple
struts.i18n.encoding=utf-8
!--struts.action.extension=do
struts.objectFactory =spring
当我把struts.action.extension=do注释去掉时,页面将找不到,即出现404 Not Found的错误。
若把struts.action.extension=do注释掉后,就能正常访问页面。

请教各位大虾有遇过这样的问题吗?指导下小弟,在此谢先了!

解决方案 »

  1.   

    路径问题。
    struts.action.extension=do 这个是提示struts2的action默认后缀嘛,不写默认为action啊,和这个应该没关系嘛
      

  2.   

    页面请求怎么写的啊:1.当我把struts.action.extension=do注释去掉时,页面将找不到,即出现404 Not Found的错误。应该写:test.do
      

  3.   

    在我的项目中有WEB-INF/ftl/login.ftl,我是直接访问freeer的静态页面的,如http://localhost:8080/xxx/login,如果我把struts.action.extension=do注释掉,页面能正常访问,
    若把struts.action.extension=do注释去掉时,页面将找不到,即出现404 Not Found的错误
      

  4.   

    struts.action.extension=do注释掉
    后使用http://localhost:8080/xxx/login.action访问
      

  5.   

    1.
    http://localhost:8080/xxx/login使用struts2默认后缀名,struts2默认配置struts.action.extension=action,,。
    即action或者不写。
    http://localhost:8080/xxx/login

    http://localhost:8080/xxx/login.action都能正常访问。2.
    struts.action.extension=do是你自定义后缀名必须加do
    即:http://localhost:8080/xxx/login.do
      

  6.   

    嗯,谢谢你指导,这个我明白。我现在的问题是,struts2与freeer结合开发,只要你在struts.properties的配置文件里加上struts.action.extension这一句后,无论struts.action.extension的值是什么,它都会出现错误的。如果视图是JSP就不会出现这种错误。
    补充:
    在我的项目中有WEB-INF/ftl/login.ftl,我是直接访问freeer的静态页面的,如http://localhost:8080/xxx/login,如果我把struts.action.extension=do注释掉,页面能正常访问, 
    若把struts.action.extension=do注释去掉时,页面将找不到,即出现404 Not Found的错误
      

  7.   

    哈,谢谢这位仁兄的指导!这样访问是没问题的了,但小弟不明白的是:我的静态页面文件名是login.ftl,为什么login.action后同样是指向login.ftl呢?那如果我在struts.xml配置了一个名为<action name="login">的action,如果我再次输入http://localhost:8080/xxx/login.action后,系统是找login.ftl还是去找action那个请求呢?
      

  8.   

    <action name="*"> 
        <result type="freeer">/WEB-INF/ftl/{1}.ftl </result> 
    </action>以上配置是struts2通配符配置方式。http://localhost:8080/xxx/login.action
    相当配置
    <action name="login"> 
        <result type="freeer">/WEB-INF/ftl/login.ftl </result> 
    </action>
      

  9.   

    哦,明白了!谢谢你!
    struts.xml:
            <action name="login" class="login">
                <result name="error" type="freeer">/WEB-INF/ftl/error.ftl</result>
                <result name="success" type="freeer">/WEB-INF/ftl/welcome.ftl</result>        
            </action>
            <action name="*">
                <result type="freeer">/WEB-INF/ftl/{1}.ftl</result>
            </action>
        </package>
         </struts>
    在我的项目中有WEB-INF/ftl/login.ftl。
    我想访问login.ftl这个静态页面,请教应该怎样配置才好呢?
      

  10.   

    建议以下形式配置:
    <action name="login" class="login"> 
       <result name="error" type="freeer">/WEB-INF/ftl/error.ftl </result> 
       <result name="success" type="freeer">/WEB-INF/ftl/welcome.ftl</result>        
    </action>
      

  11.   


    这样的话是不是要为每个静态页面写个Action类?其实我不login.ftl是个静态页面,我不想通过action而是直接访问的,如我输入http://localhost:8080/xxx/login.ftl就直接访问login.ftl,而不用转,就像我项目中有一个纯静态的login.html页面那样,输入http://localhost:8080/xxx/login.html这个页面。非常感谢你能抽出这么多宝贵的时间来为我解答难题!
      

  12.   

    大家好   最近我也在看S2和Freeer的整合   可是有点不是很明白  就是 用Freeer作为模版 来充当显示层  与用jsp相比有什么优点啊?