Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [java-struts]Eccezione incomprensibile

    Salve! Ho creato con Eclipse un progetto java utilizzando le librerie di struts 1.3.8. Il mio struts-config è il seguente:

    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
    
    <struts-config>
    	<form-beans >
    		<form-bean name="homeForm" type="form.HomeForm" />
    		
    	</form-beans>
    	
    	<global-exceptions />
    	<global-forwards />
    	<action-mappings >
    		<action
    		       attribute="homeForm"
    		       
    		       name="homeForm"
    		       path="/home"
    		       scope="request"
    		       type="action.HomeAction" >
    			<forward name= "success" path="/jsp/home.jsp"/>
    		</action>
    	</action-mappings>
    	
    	<message-resources parameter="ApplicationResources" />
    </struts-config>
    Ho una jsp home.jsp con dei form, i cui campi sono stati internazionalizzati attraverso il file ApplicationResources.
    codice:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    		<title>Home Esercitazione</title>
    	</head>
    	<body bgcolor="#FFE4E1">
    	
    		<html:form>
    	<font color="blue"><bean:message key="login.user"/></font>:<html:text property="user"/><html:errors property="user"/>
    
    	<font color="blue"><bean:message key="login.password"/></font>
    	<font color="red"><html:submit titleKey = "login.submit.value" /></font>
    		</html:form> 
    	</body>
    </html>
    Quando cerco di avviare da tomcat questa action mi comprare questa eccezione che non riesco a capire:
    codice:
     
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception 
    org.apache.jasper.JasperException
            org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    root cause 
    java.lang.NullPointerException
            org.apache.struts.taglib.TagUtils.getActionMappingName(TagUtils.java:583)
            org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:834)
            org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:467)
            org.apache.jsp.jsp.home_jsp._jspx_meth_html_005fform_005f0(home_jsp.java:102)
            org.apache.jsp.jsp.home_jsp._jspService(home_jsp.java:77)
            org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
    Mi sapreste dire di che tipo d eccezione si tratta? Se occorre, posto le classi Form e Action...
    Grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    120
    ti manca la definizione dei taglib. Hai aggiunto i tld al progetto? ti servono struts-bean.tld, struts-html.tld e struts-logic.tld

    Li definisci dentro al web.xml così:
    codice:
    <taglib>
      <taglib-uri>struts-bean</taglib-uri>
      <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
     </taglib>
     <taglib>
      <taglib-uri>struts-logic</taglib-uri>
      <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
     </taglib>
     <taglib>
      <taglib-uri>struts-html</taglib-uri>
      <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
     </taglib>
     <taglib>
      <taglib-uri>struts-tiles</taglib-uri>
      <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
     </taglib>
    dove ovviamente la location dipende da dove hai quei file, è comunque meglio metterli sotto la web-inf. All'uri puoi dare in realtà il nome che vuoi, è il nome con cui poi li vai a richiamare dentro la pagina jsp:
    codice:
    <%@ taglib uri="struts-bean" prefix="bean" %>
    <%@ taglib uri="struts-html" prefix="html" %>
    <%@ taglib uri="struts-logic" prefix="logic" %>
    (questo lo devi aggiungere all'inizio della tua pagina jsp)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.