废话少说,上代码struts-config.xml配置文件<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans>
<form-bean name="bbsForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="file" type="org.apache.struts.upload.FormFile"/>
<form-property name="forumpost" type="hk.egame.bbs.entity.BbsForumPost"/>
<form-property name="forumthread" type="hk.egame.bbs.entity.BbsForumThread"/>
<form-property name="userinfo" type="hk.egame.bbs.entity.BbsUserinfo"/>
<form-property name="forumforum" type="hk.egame.bbs.entity.BbsForumForum"/>
<form-property name="page" type="hk.egame.amms.misc.Page" />
</form-bean>
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="error" path="/error.jsp" />
</global-forwards>
<action-mappings>
<action path="/bbs/forum" type="org.springframework.web.struts.DelegatingActionProxy"
name="bbsForm" parameter="method" scope="request">
<forward name="listForum" path="/admin/form/forum_list.jsp" />
</action>
</action-mappings>
<controller bufferSize="4096"></controller>
<message-resources parameter="cn.jsprun.struts.ApplicationResources" />
<message-resources parameter="messages_zh" />
</struts-config>action
public ActionForward forumlist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) { DynaActionForm bbsForm = (DynaActionForm) form;
System.out.println(bbsForm);
.....................
return mapping.findForward(Constants.LISTFORUM);打印
null請求 :http://localhost/bbs/forum.do?method=forumlist
小弟实在不解,那里出问题了,以前走正常的...........
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans>
<form-bean name="bbsForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="file" type="org.apache.struts.upload.FormFile"/>
<form-property name="forumpost" type="hk.egame.bbs.entity.BbsForumPost"/>
<form-property name="forumthread" type="hk.egame.bbs.entity.BbsForumThread"/>
<form-property name="userinfo" type="hk.egame.bbs.entity.BbsUserinfo"/>
<form-property name="forumforum" type="hk.egame.bbs.entity.BbsForumForum"/>
<form-property name="page" type="hk.egame.amms.misc.Page" />
</form-bean>
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="error" path="/error.jsp" />
</global-forwards>
<action-mappings>
<action path="/bbs/forum" type="org.springframework.web.struts.DelegatingActionProxy"
name="bbsForm" parameter="method" scope="request">
<forward name="listForum" path="/admin/form/forum_list.jsp" />
</action>
</action-mappings>
<controller bufferSize="4096"></controller>
<message-resources parameter="cn.jsprun.struts.ApplicationResources" />
<message-resources parameter="messages_zh" />
</struts-config>action
public ActionForward forumlist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) { DynaActionForm bbsForm = (DynaActionForm) form;
System.out.println(bbsForm);
.....................
return mapping.findForward(Constants.LISTFORUM);打印
null請求 :http://localhost/bbs/forum.do?method=forumlist
小弟实在不解,那里出问题了,以前走正常的...........
public ActionForward forumlist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {已经为空,debug看不到任何值
public void forumlist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) { DynaActionForm bbsForm = (DynaActionForm) form;
System.out.println(form+"||"+mapping);
}
struts-config.xml的<action type="">我没像你那样写过,
我知道的写法是:在struts-config.xml里加上以下代码:
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
type就不需要了,但是path要和applicationContext.xml里配置的action的名字保持一致。
action
public ActionForward forumlist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {DynaActionForm bbsForm = (DynaActionForm) form;在这里写上从页面上传来的表单所传信息的类,例如:
UserInfo userInfo=(UserInfo)bbsForm.get("userinfo");System.out.println(bbsForm);
.....................
return mapping.findForward(Constants.LISTFORUM);
问题是 参数form就是空.........