LoginForm ss=new LoginForm(); 这样写当然都是NULL了.
你根本就同有用提交后的FORM
System.out.println(ss.getName());
System.out.println(ss.getPassword());
return null;
要用这里的值
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
你根本就同有用提交后的FORM
System.out.println(ss.getName());
System.out.println(ss.getPassword());
return null;
要用这里的值
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
LoginForm ss= (LoginForm)form
以后:
有空指针异常。不知道为什么。。
严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at com.dong.company.action.LoginaAction.execute(LoginaAction.java:47)
警告: Unhandled Exception thrown: class java.lang.NullPointerException
2008-4-15 16:39:43 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at com.dong.company.action.LoginaAction.execute(LoginaAction.java:47)
我用myeclipse建完LoginForm然后再建loginaction,想添加loginform却找不到只好手写了
<?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="loginForm" type="com.dong.company.form.LoginForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="loginAction"
name="loginAction"
path="/logina"
type="com.dong.company.action.LoginaAction"
input ="index.jsp">
<forward name="error" path="error.jsp" />
<forward name="success" path="success.jsp" />
</action> </action-mappings> <message-resources parameter="com.dong.company.ApplicationResources" />
</struts-config>
public class LoginaAction 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) {
LoginForm ss = (LoginForm) form;
actionForward里的这个form应该是“ActionForm”啊,还是应该是已经定义了的具体的那个form啊比如loginform?