标题:请教struts的问题
只看楼主
ITMM
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2006-8-22
 问题点数:0 回复次数:1 
请教struts的问题

问题,通过超链接,进入相应页面的action里面,但是在action里面调用和这action相关的ActionForm Bean时,却执行不下去了。
Action的相关代码如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Mii_SH_changguiTgForm mii_SH_changguiTgform = (Mii_SH_changguiTgForm) form;
//Mii_SH_changguiTgForm 是和次Actiong关联的ActionForm Bean
HttpSession session = request.getSession();
System.out.println("进入审核Action");//程序执行到这一步就不执行,不知道什么原因?
String strhide = mii_SH_changguiTgform.getHide();
String strbaxh = mii_SH_changguiTgform.getBaxh();
System.out.println("strhide::"+strhide+" strbaxh::"+strbaxh);
//String strspsj = icp_SHchangguiViewform.getSpsj();
String strID =(String) session.getAttribute("strztid");
Vector v = new Vector();
String strSPSJ="";

if(strhide==null)
{
System.out.println("texta1");
String ztid = request.getParameter("ztid");
session.setAttribute("strztid",ztid);
request.setAttribute("v", v);
return mapping.findForward("mii_SH_changguiTg");

}
。。。。。。上面只是一部分,但应该也足够了,

Mii_SH_changguiTgForm .java的相关代码如下:

package com.yourcompany.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/**
* MyEclipse Struts
* Creation date: 04-10-2007
*
* XDoclet definition:
* @struts.form name="mii_SH_changguiTgForm"
*/
public class Mii_SH_changguiTgForm extends ActionForm {
/*
* Generated Methods
*/
/** spsj property */
private String spsj;

/** baxh property */
private String baxh;

private String hide;
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}

/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}

/**
* Returns the spsj.
* @return String
*/
public String getSpsj() {
return spsj;
}

/**
* Set the spsj.
* @param spsj The spsj to set
*/
public void setSpsj(String spsj) {
System.out.println("setHide::"+spsj);
this.spsj = spsj;
}

/**
* Returns the baxh.
* @return String
*/
public String getBaxh() {
return baxh;
}

/**
* Set the baxh.
* @param baxh The baxh to set
*/
public void setBaxh(String baxh) {
System.out.println("setBaxh::"+baxh);
this.baxh = baxh;
}

public String getHide() {
System.out.println("getHide::"+hide);
return hide;
}

/**
* Set the ztid.
* @param ztid The ztid to set
*/
public void setHide(String hide) {
System.out.println("setHide::"+hide);
this.hide = hide;
}


}

struts-config.xml的相关配置如下:
<form-beans >
。。。。。
<form-bean name="mii_SH_changguiTgForm" type="com.yourcompany.struts.form.Mii_SH_changguiTgForm" />
</form-beans>

<action-mappings >

<action
attribute="mii_SH_changguiTgForm"
input="/SHchang/mii_SH_changguiView.jsp"
name="mii_SH_changguiTgForm"
path="/mii_SH_changguiTg"
scope="request"
type="com.yourcompany.struts.action.Mii_SH_changguiTgAction">
<forward name="mii_SH_changguiView" path="/SHchang/mii_SH_changguiView.jsp" />
<forward name="mii_SH_changguiTg" path="/SHchang/mii_SH_changguiTg.jsp" />
</action>
</action-mappings>

通过tomcat看到后台显示信息为:
进入审核Action
2007-4-10 19:26:56 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class java.lang.NullPointerException


不知道什么地方错了,恳请各位高手解答,万分感谢!

搜索更多相关主题的帖子: struts 
2007-04-10 19:54
ITMM
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2006-8-22
得分:0 
回复:(ITMM)请教struts的问题

问题已经解决,呵呵,谢谢


2007-04-10 20:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-130831-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.947192 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved