String index out of range: 0?

Mrpublic 2009-03-10
color=green] com.sun.facelets.FaceletViewHandler handleRenderException
嚴重的: Error Rendering View[/fupl/log.xhtml]
java.lang.StringIndexOutOfBoundsException: String index out of range: 0?[/color]

我看了一下是view-id 為null.
怎么可能呢?
我把提交按鈕<h:commandButton action="#{identity.login}" value="Login" />
改為:<h:commandButton action="#{authenticator.authenticate}" value="Login" />
就沒有錯了呀


我是把seam工程自生成的Authenticator.java的
boolean authenticate()修改了一下子,但我認為應該不影響使用identity.login 呀???


不知為什麽現在一點問題都沒有了!!哎,奇怪。。。
Mrpublic 2009-03-10
我的log.page.xml

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd">

   <navigation from-action="#{identity.login}">
      <rule if="#{identity.loggedIn}">
         <redirect view-id="/index.xhtml"/>
      </rule>
   </navigation>

</page>
Mrpublic 2009-03-10
我的log.xthml
界面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view contentType="text/html"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:s="http://jboss.com/products/seam/taglib"
        xmlns:rich="http://richfaces.org/rich">

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <ui:include src="head.xhtml" />
     <rich:spacer width="100%" height="200px"/>
    <div  align="center">
    <h:form>
         <div>
            <h:panelGrid columns="3">
            <h:outputText value="用戶名" />
            <h:inputText value="#{identity.username}"  id="name"/>
            <h:message for="name" />
            <h:outputText value="密碼" />
            <h:inputSecret value="#{identity.password}"  id="pw"/>
            <h:message for="pw"  />
            <h:outputText value="驗證碼"/>
            <h:inputText value="#{verifyCode.verifyCode}"/>
            <a4j:mediaOutput element="img" cacheable="false" session="false"
            createContent="#{verifyCode.paintVerifyCode}"  value="#{imageData}"
            mimeType="image/jpeg" border="0"/>
            </h:panelGrid>
         </div>
         <div> <h:commandButton action="#{identity.login}" value="Login" /></div>
     </h:form>
     </div>

</f:view>

我在網上查了一下,類似問題說是中文亂碼問題,我用的是seam2.1.1GA,我也按他們說的把jboss服務器下的deploy/jboss-web.deployer/server.xml
加入了utf-8 還是不行。。。
andyhan 2009-03-11
是不是文件编码的问题,统一使用UTF-8,尤其是页面文件。
Mrpublic 2009-03-11
是頁面不跳轉的問題,不曉得為什麽不跳轉
log.page.xml
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd">

   <navigation from-action="#{identity.login}">
      <rule if="#{identity.loggedIn}">
         <redirect view-id="/index.xhtml"/>
      </rule>
   </navigation>

</page>
Mrpublic 2009-03-11
我在登錄頁面點
<h:commandButton action="#{identity.login}" value="Login" />

就跳出那個錯?
what's wrong? anyone else can help me? thanks!
andyhan 2009-03-11
log.xthml 的文件编码改为UTF-8
或者用英文替换里面的正体中文。
Mrpublic 2009-03-11
andyhan 写道
log.xthml 的文件编码改为UTF-8
或者用英文替换里面的正体中文。


謝謝關注,我改了也不行呀
主要是identity 的原因吧

我把log.xhtml 中的提交頁面中的
<h:commandButton action="#{identity.login}" value="Login" />
改為
<h:commandButton action="#{authenticator.authenticate}" value="Login" />
就沒問題了

我是把seam工程自帶的Authenticator.java 的
public boolean authenticate()方法修改了,但我認為這個對用identity沒影響呀,為什麽用identity就報 String index out of range: 0
Global site tag (gtag.js) - Google Analytics