命令按钮链接到Spring Web Flow Project中的错误路径名

时间:2014-01-30 19:32:14

标签: spring richfaces spring-webflow commandbutton

我试图将两个数字加在一起并显示输出,但我有渲染问题。

我从ajax日志中得到了这个。 (为了便于阅读而空格不清)

info [12:44:10.893]: Element error 
<error>
  <error-name>
    class com.sun.faces.context.FacesFileNotFoundException
  </error-name>
  <error-message>
    <![CDATA[/WEB-INF/WEB-INF/intro.xhtml Not Found in ExternalContext as a Resource]]>
  </error-message>
</error>

我看不到它在路径名中获取两个WEB-INF文件夹的位置。

这个问题的第二部分是我不确定应该在哪里调用calculator.sum。这可能会影响结果或需要在单独的问题中。 #{calculator.sum}是单击按钮时调用的输出。

这是我正在编辑的表单。      

 <rich:panel id="UserManagePanel" header="Welcome to test">

 <a href="main">Enter The WebFlow</a>
  <br/>
  <br/>
  <br/>
    <h:inputText id="additive1" value="#{calculator.a}"/>
  <br/>
    <h:inputText id="additive2" value="#{calculator.b}"/>
  <br/>
    <a4j:commandButton type="button" id="btn_add" action="#{calculator.sum}" value="Add" reRender="out" execute="@form"/>
  <br/>

  <a4j:outputPanel id="out">
    <h:outputText value="#{calculator.sum}" rendered="true"/>
  </a4j:outputPanel>
  <br/>

  <a4j:log/>

   </rich:panel>
  </h:form>

支持文档:

主flow.xml

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/webflow
        http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd">

    <view-state id="Page2">
        <transition on="gotoPage3" to="Page3"/>
        <!--  <transition on="printDets">
            <evaluate expression="userBean.printDetails()" />
        </transition> -->
    </view-state>

    <view-state id="Page3">
        <transition on="gotoSubFlow" to="Page3subflow"/>
        <transition on="gotoPage5" to="Page5"/>
    </view-state>

    <view-state id="Page5">
    </view-state>

    <subflow-state id="Page3subflow" subflow="subflow1">
    </subflow-state>

    <end-state id="finish" />

</flow>

的web.xml

<?xml version="1.0" encoding="ASCII"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

<!-- The master configuration file for this Spring web application -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/config/web-application-config.xml
    </param-value>
</context-param>

<!-- Declare Spring Security Facelets tag library 
<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param> -->

<!-- Enforce UTF-8 Character Encoding -->
<filter>
    <filter-name>charEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>charEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Enables Spring Security -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

<!--  
<context-param>
    <param-name>org.richfaces.skin</param-name>
    <param-value>joshCustom</param-value>
</context-param>
-->
<context-param>
    <param-name>org.richfaces.enableControlSkinning</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>facelets.SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<!-- Enables special Facelets debug output during development -->
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<!-- Causes Facelets to refresh templates during development -->
<context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
</context-param>

<!--
    Uncomment this to disable partial state saving when using Apache MyFaces 2 !!
<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>
-->

<!-- Loads the Spring web application context -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>

<!-- Map all /spring requests to the Dispatcher Servlet for handling -->
<servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/spring/*</url-pattern>
</servlet-mapping>

<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- Just here so the JSF implementation can initialize -->
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>

<!-- Added for JAX-WS compatibility -->
<servlet>
    <servlet-name>JAX-WS Servlet</servlet-name>
    <servlet-class>demo.SimpleServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>JAX-WS Servlet</servlet-name>
    <url-pattern>/SimpleService</url-pattern>
</servlet-mapping>



  <!-- The welcome file -->
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app><?xml version="1.0" encoding="ASCII"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

    <!-- The master configuration file for this Spring web application -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/config/web-application-config.xml
        </param-value>
    </context-param>

    <!-- Declare Spring Security Facelets tag library 
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
    </context-param> -->

    <!-- Enforce UTF-8 Character Encoding -->
    <filter>
        <filter-name>charEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Enables Spring Security -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!--  
    <context-param>
        <param-name>org.richfaces.skin</param-name>
        <param-value>joshCustom</param-value>
    </context-param>
    -->
    <context-param>
        <param-name>org.richfaces.enableControlSkinning</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <!-- Enables special Facelets debug output during development -->
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <!-- Causes Facelets to refresh templates during development -->
    <context-param>
        <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
        <param-value>1</param-value>
    </context-param>

    <!--
        Uncomment this to disable partial state saving when using Apache MyFaces 2 !!
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>false</param-value>
    </context-param>
    -->

    <!-- Loads the Spring web application context -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- The front controller of this Spring Web application, responsible for handling all application requests -->
    <servlet>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value></param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

    <!-- Map all /spring requests to the Dispatcher Servlet for handling -->
    <servlet-mapping>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>

    <!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Just here so the JSF implementation can initialize -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>

    <!-- Added for JAX-WS compatibility -->
    <servlet>
        <servlet-name>JAX-WS Servlet</servlet-name>
        <servlet-class>demo.SimpleServiceImpl</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>JAX-WS Servlet</servlet-name>
        <url-pattern>/SimpleService</url-pattern>
    </servlet-mapping>

  <!-- The welcome file -->
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app>

Java类Calculator.java

package demo;

import javax.faces.bean.*;

import org.springframework.stereotype.Component;

@ManagedBean
@Component
@ViewScoped
public class Calculator implements java.io.Serializable{

      private static final long serialVersionUID = -3832235132261771583L;

      private int _a;
      private int _b;

      public int getA() { return _a; }
      public void setA(int a) { _a = a; }

      public int getB() { return _b; }
      public void setB(int b) { _b = b; }

      public int getSum()
      {
        return _a + _b;
      }

}

我正在使用的库: 使用Richfaces 4.3.4 Spring Security 3.1.3 JSTL 1.2.1 Spring 3.2.0.RELEASE

2 个答案:

答案 0 :(得分:0)

由于calculator.sum仅返回数字(并且在后台不执行任何操作),因此单击按钮时无需调用它。

我不知道导致错误的原因,但WEB-INF是配置文件和类似的东西。如果您有任何(x)html页面,请将它们移出。

答案 1 :(得分:0)

要实现这一目标,必须要做一些事情。

1)来自flowlistener下的webmvc-config.xml的WEB-INF /。
2)并且必须习惯至少调试它 3)表格必须在标签中。
4)网址必须使用网络流

http://localhost:8080/CLPWeb/spring/grantSearchFlow?test

  rather than

http://localhost:8080/CLPWeb/spring/WEB-INF/templates/views/test.xhtml

使用url作为代码来验证它。