开发者

Eclipse Struts Error on line with bean:write

Error Report after submitting input.jsp is passed through input.do when bean:write is called in success.jsp

HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message 

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

exception 

org.apache.jasper.JasperException:javax.servlet.ServletException:javax.servlet.jsp.JspException: Cannot find bean quote in scope request
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
        org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean quote in scope request
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
    org.apache.jsp.success_jsp._jspService(success_jsp.java:82)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)             org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

javax.servlet.jsp.JspException: Cannot find bean quote in scope request
    org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:940)
    org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286)
    org.apache.jsp.success_jsp._jspx_meth_bean_005fwrite_005f0(success_jsp.java:175)
    org.apache.jsp.success_jsp._jspx_meth_html_005fhtml_005f0(success_jsp.java:124)
    org.apache.jsp.success_jsp._jspService(success_jsp.java:73)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.13

struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="quoteForm" type="com.yourcompany.struts.form.QuoteForm" />
    <form-bean name="inputForm" type="com.yourcompany.struts.form.InputForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="inputForm"
      input="/input.jsp"
      name="inputForm"
      path="/input"
      scope="request"
      type="com.yourcompany.struts.action.InputAction">
      <forward name="failure" path="/empty.jsp" />
      <forward name="success" path="/success.jsp" />
    </action>


  </action-mappings>

  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>

input.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://jak开发者_开发技巧arta.apache.org/struts/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>

<html> 
    <head>
        <title>JSP for InputForm form</title>
    </head>
    <body>
        <html:form action="/input">
            author : <html:text property="author"/><html:errors     property="author"/><br/>
            quote : <html:textarea property="quote"/><html:errors property="quote"/><br/>
            <html:submit/><html:cancel/>
        </html:form>
    </body>
</html>

inputAction.java

/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yourcompany.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.InputForm;

/** 
 * MyEclipse Struts
 * Creation date: 05-02-2011
 * 
 * XDoclet definition:
 * @struts.action path="/input" name="inputForm" input="/form/input.jsp" scope="request" validate="false"
 * @struts.action-forward name="failure" path="/empty.jsp"
 * @struts.action-forward name="success" path="/success.jsp"
 */
public class InputAction extends Action {
    /*
     * Generated Methods
     */

    /** 
     * Method execute
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        InputForm inputForm = (InputForm) form;

        if(inputForm.getAuthor().equals(null) || inputForm.getQuote().equals(null)){
            request.setAttribute("author", inputForm.getAuthor());
            request.setAttribute("quote", inputForm.getQuote());
            return mapping.findForward("failure");
        }
        return mapping.findForward("success");
    }
}

success.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />

    <title>success.jsp</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>

  <body>
        <bean:write name="quote" scope="request" />
        <bean:write name="author" scope="request" /> 
    This a struts page. <br>
  </body>
</html:html>


check your inputform bean i think there is no appropriate getter setter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜