日期:2014-05-18  浏览次数:20692 次

发神经了,暴了一个org.apache.jasper.JasperException

说明一下,我用webwork开发的,我写一个Tag类。要传一个Useres实体的属性。第,我在使用这个标签是<user:toolTag user="#session[user]"/>它就暴了这一个错。我怎么样将当session中的user为null时,不暴错呢?要是数据类型转不了。
如果用${user}这个更气,就是用了tomcat5.5就暴这个错,用了tomcat6.0就没有错。哎。。。。。

标签代码如下。
Java code

package com.gz.koal.sys.tag;

import java.io.IOException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.gz.koal.model.Useres;
import com.opensymphony.xwork.DefaultActionInvocation;
/**
 * 工具栏标签
 * @author Administrator
 *
 */
public class ToolTag extends TagSupport {

    private static final long serialVersionUID = 1L;
    private static final Log LOG = LogFactory.getLog(DefaultActionInvocation.class);
    
    private Useres user=null;

    public static long getSerialVersionUID() {
        
        return serialVersionUID;
    }

    public Useres getUser() {
        return user;
    }

    public void setUser(Useres user) {
        this.user = user;
    }

    
    public int doStartTag()  {
        JspWriter out=this.pageContext.getOut();
        try {
            
            out.println("<div  align='right' style='background: #dfdddd'>");
            if(user==null)
            {
                out.println("<a href='/webwork/jsp/login.jsp' target='_parent'>[登录]</a> ");
                out.println("<a href='/webwork/jsp/register.jsp' target='_parent'>[注册]</a> ");
                
                
            }else
            {   
                
                out.println("<a href='/webwork/jsp/control.jsp' target='_parent'>["+user.getUserName()+"]设置</a>");
                out.println("<a href='/webwork/user!undo.action'>[注销]</a> ");
            }
            out.println("<a href='/webwork/jsp/index.jsp' target='_parent'>[返回主页]</a>");
            out.println("</div><br/>");
          
        } catch (IOException e) {
            LOG.error("标签文件发生IO流异常"+e.getMessage());
            
        }catch(Exception e)
        {
            LOG.error("标签文件发生未知异常"+e.getMessage());
        }
        return SKIP_BODY;
    }
    
    

}



2008-12-26 10:48:41 org.apache.catalina.core.ApplicationDispatcher invoke
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to convert string "#session['user']" to class "com.gz.koal.model.Useres" for attribute "user": Property Editor not registered with the PropertyEditorManager
at org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:887)
at org.apache.jsp.jsp.index_jsp._jspx_meth_user_005ftoolTag_005f0(index_jsp.java:101)
at org.apache.jsp.jsp.index_jsp._jspService(index_jsp.java:70)

------解决方案--------------------
com.gz.koal.model.Useres 这里面有user属性吗 ??
还是session中没这个属性 ?还是没SET GET方法