回 帖 发 新 帖 刷新版面

主题:[讨论]新手jsf问题

刚学J2EE,用JSF进行WEB开发
在URL中输入:http://localhost:8081/JSFLoginDemo/userLogin.faces 提出如下错误
type Exception report

message 
description The server encountered an internal error () that prevented it from fulfilling this request.

exception 
javax.servlet.ServletException: userName 
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)


root cause 
java.lang.IllegalArgumentException: userName 
javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:535)
javax.faces.component.UIComponentBase.setId(UIComponentBase.java:333)
javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:218)
javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:476)
javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:660)
javax.faces.webapp.UIComponentClassicTagBase.doStartTag.........

userLogin.jsp的代码如下:
<body>
 <f:view>
    <f:loadBundle basename="Messages" var="bundle"/>
    <h:outputText value="#{bundle.login_lable}"></h:outputText>
    
    <h:form id="loginForm">
    
    <h:outputLabel for="userName" 
    value="#{bundle.username_lable}"></h:outputLabel>
    
    <h:inputText id="userName " value="#{UserBean.userName}"></h:inputText>
    
           <br>password:<h:inputSecret id="password" 
           value="#{UserBean.password}"></h:inputSecret><br>

           <h:commandButton id="submit" type="submit"
           action="{UserBean.login}"  value="登录"></h:commandButton>
                
    </h:form>
            
 </f:view>
</body>
请各位大侠指点,万分感激!!

回复列表 (共1个回复)

沙发

怎么没有人回复呢,是不是我的问题描述的不清楚,那我在说清楚点,知道的各位大侠帮帮忙啊!
web.xml的内容如下:
<context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
  </context-param>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

faces.congif.xml的内容如下:
<managed-bean>
<managed-bean-name>UserBean</managed-bean-name>
<managed-bean-class>com.jsfdemo.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
    property-name>userName</property-name>
    <property-class>java.lang.String</property-class>
    <value></value>
    </managed-property>
    <managed-property>
    <property-name>password</property-name>
    <property-class>java.lang.String</property-class>
    <value></value>
</managed-property>
</managed-bean>
    <navigation-rule>
    <from-view-id>/userLogin.jsp</from-view-id>
      <navigation-case>
        <description>登录成功</description>
        <from-outcome>success</from-outcome>
        <to-view-id>/userLoginSuccess.jsp</to-view-id>
       </navigation-case>
      <navigation-case>
        <description>登录失败</description>
        <from-outcome>failure</from-outcome>
        <to-view-id>/userLogin.jsp</to-view-id>
      </navigation-case></navigation-rule>
    <navigation-rule>
        <from-view-id>/userLoginSuccess.jsp</from-view-id>
        </navigation-rule></faces-config>

我来回复

您尚未登录,请登录后再回复。点此登录或注册