用struts报错,不知道是什么意思

Byakuya 2007-03-15 01:17:59
报错:
type Exception report

message

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

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
org.apache.struts.taglib.TagUtils.pageURL(TagUtils.java:1070)
org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:449)
org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:311)
org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:463)
org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:341)
org.apache.jsp.hello_jsp._jspx_meth_html_link_0(hello_jsp.java:122)
org.apache.jsp.hello_jsp._jspx_meth_html_html_0(hello_jsp.java:94)
org.apache.jsp.hello_jsp._jspService(hello_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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

------------------------------------------------------
HelloAction.java文件:

package hello;

import org.apache.struts.action.*;
import javax.servlet.http.*;

public class HelloAction extends Action {
public ActionForward execute(ActionMapping map,ActionForm form,
HttpServletRequest request,HttpServletResponse response)throws Exception{

String para=(String)request.getParameter("place");
if(para.equals("1"))
return(map.findForward("HelloWorld_1"));
else
return(map.findForward("HelloWorld_2"));
}

}

------------------------------------------------------
web.xml文件:

<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>HelloApp Struts Application</display-name>
<Servlet>
<Servlet-name>action</Servlet-name>
<Servlet-class>org.apache.struts.action.ActionServlet</Servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</Servlet>
<Servlet-mapping>
<Servlet-name>action</Servlet-name>
<url-pattern>*.do</url-pattern>
</Servlet-mapping>
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>

------------------------------------------------------
struts-config.xml文件:

<struts-config>
<action-mappings>
<action path="/HelloWorld"
type="hello.HelloAction"
scope="request"
validate="true">
<forward name="Hello_1" path="/HelloWorld_1.jsp"/>
<forward name="Hello_2" path="/HelloWorld_2.jsp"/>
</action>
</action-mappings>
<message-resources parameter="hello.application"/>
</struts-config>

------------------------------------------------------
hello.jsp文件:

<%@ page language="java" contentType="text/html; charset=GB2312"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html:html>
<body>
<html:link page="/HelloWorld.do?place=1">HelloWorld_1</html:link>
<html:link page="/HelloWorld.do?place=2">HelloWorld_2</html:link>
</body>
</html:html>
------------------------------------------------------
...全文
430 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
我才天生 2007-04-25
  • 打赏
  • 举报
回复
我也是同样的问题,无法解决
xinghao_1984 2007-03-18
  • 打赏
  • 举报
回复
改了以后从启一下服务器
baobeiSimple 2007-03-17
  • 打赏
  • 举报
回复


按hubing2008(曾经沧海难为水,除却巫山不是云(☆☆☆☆)) 的修改
然后
<action path="/HelloWorld"
type="hello.HelloAction"
scope="request"
validate="true">
<forward name="Hello_1" path="/HelloWorld_1.jsp"/>
<forward name="Hello_2" path="/HelloWorld_2.jsp"/>

</action>
这里面加上name的属性
wuhuawu09 2007-03-15
  • 打赏
  • 举报
回复
空指针异常。。是哪个参数没得到值吧。。。。
Byakuya 2007-03-15
  • 打赏
  • 举报
回复
谢谢,我改了,重新启动,还是报跟刚才一样的错误,不知道是不是那些xml文件有问题?
古月一刀2005 2007-03-15
  • 打赏
  • 举报
回复
直观的说就是:
return(map.findForward("HelloWorld_1"));是对应你的struts配置文件的name属性,应该改成return(map.findForward("Hello_1"));

希望帮到你!!!
古月一刀2005 2007-03-15
  • 打赏
  • 举报
回复
应该改成:
public class HelloAction extends Action {
public ActionForward execute(ActionMapping map,ActionForm form,
HttpServletRequest request,HttpServletResponse response)throws Exception{

String para=(String)request.getParameter("place");

String target="Hello_2";
if(para.equals("1")){
target="Hello_1";
}

return map.findForward(target);

}
lip009 2007-03-15
  • 打赏
  • 举报
回复
public class HelloAction extends Action {
public ActionForward execute(ActionMapping map,ActionForm form,
HttpServletRequest request,HttpServletResponse response)throws Exception{

String para=(String)request.getParameter("place");

String target="Hello_2";
if(para.equals("1")){
target="Hello_1";
}

return map.findForward(target);

}
shizha 2007-03-15
  • 打赏
  • 举报
回复
return(map.findForward("HelloWorld_1"));这里是对应你的struts配置文件的name属性,应该改成return(map.findForward("Hello_1"));而不应该是HelloWorld_1(HelloWorld_1.jsp),希望能帮到你!!

祝你在java路上越走越远!!!!!!!!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧