求教各位,我想頁面加載的時候就調用query()方法
url 應該怎麼寫?
我知道Action的是http://localhost:8080.../member.do
DispatchAction的是http://localhost:8080.../member.do?method=query
那LookupDispatchAction 的是什麽???????????急 啊public class MemberAction extends LookupDispatchAction {
//重寫抽象方法
//用一個MAP保存資源文件KEY和方法名的映射
protected Map getKeyMethodMap() {
System.out.println("進入方法");
Map map = new HashMap();
map.put("info.member.query", "query");
map.put("info.member.insert", "insert");
return map;
}
public ActionForward query(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MemberForm memberForm = (MemberForm) form;
try{request.setCharacterEncoding("utf8");}catch(Exception e){}
String memid = memberForm.getMemid();
String name = memberForm.getName();
String sex = memberForm.getSex();
String type = memberForm.getType();
System.out.println("request: " + request.getParameter("name"));
System.out.println(memid);
System.out.println(name);
System.out.println(sex);
System.out.println(type);
DataClass dc = new DataClass();
ArrayList al = dc.queryMember(memid, name, sex, type);
request.setAttribute("al", al);
return mapping.findForward("member");
}
url 應該怎麼寫?
我知道Action的是http://localhost:8080.../member.do
DispatchAction的是http://localhost:8080.../member.do?method=query
那LookupDispatchAction 的是什麽???????????急 啊public class MemberAction extends LookupDispatchAction {
//重寫抽象方法
//用一個MAP保存資源文件KEY和方法名的映射
protected Map getKeyMethodMap() {
System.out.println("進入方法");
Map map = new HashMap();
map.put("info.member.query", "query");
map.put("info.member.insert", "insert");
return map;
}
public ActionForward query(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MemberForm memberForm = (MemberForm) form;
try{request.setCharacterEncoding("utf8");}catch(Exception e){}
String memid = memberForm.getMemid();
String name = memberForm.getName();
String sex = memberForm.getSex();
String type = memberForm.getType();
System.out.println("request: " + request.getParameter("name"));
System.out.println(memid);
System.out.println(name);
System.out.println(sex);
System.out.println(type);
DataClass dc = new DataClass();
ArrayList al = dc.queryMember(memid, name, sex, type);
request.setAttribute("al", al);
return mapping.findForward("member");
}
解决方案 »
- jms发送消息时设置MessageProducer.setTimeToLive,超时被移除的消息如何获取?
- html改为jsp后session就不丢失了!哪位帮忙看看啊
- 求助!weblogic发布失败- -
- 请问怎样经行Java数据库开发,以及如何选择数据库?
- 什么是上下文?
- 请高手讲解下webwork框架,它和struts,sping有何优势和略势?为何选用webwork做开发?
- 急!Eclipse调试错误
- 郁闷,Weblogic 8.1 sp1数据库连接问题
- 每加一颗星要得到多少分
- struts2
- 我用struts2 上传文件为什么会出现这种错误?
- 请问service层中怎么拿到httpSession?
public abstract class LookupDispatchAction
extends DispatchAction An abstract Action that dispatches to the subclass mapped execute method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the parameter property of the corresponding ActionMapping. To configure the use of this action in your struts-config.xml file, create an entry like this: <action path="/test"
type="org.example.MyAction"
name="MyForm"
scope="request"
input="/test.jsp"
parameter="method"/> which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties: button.add=Add Record
button.delete=Delete Record And your JSP would have the following format for submit buttons: <html:form action="/test">
<html:submit property="method">
<bean:message key="button.add"/>
</html:submit>
<html:submit property="method">
<bean:message key="button.delete"/>
</html:submit>
</html:form> Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are: protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.add", "add");
map.put("button.delete", "delete");
return map;
} public ActionForward add(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// do add
return mapping.findForward("success");
} public ActionForward delete(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// do delete
return mapping.findForward("success");
}
<!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="memberForm" type="lianxi_struts.form.MemberForm" />
<form-bean name="diplayForm" type="lianxi_struts.form.DiplayForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="memberForm"
input="/member.jsp"
name="memberForm"
path="/member"
parameter="method"
scope="request"
type="lianxi_struts.action.MemberAction">
<forward name="member" path="/member.jsp"></forward>
</action>
</action-mappings> <message-resources parameter="lianxi_struts.ApplicationResources" />
</struts-config>
它报什么错呢?
org.apache.struts.actions.LookupDispatchAction.getLookupMapName(LookupDispatchAction.java:230)
org.apache.struts.actions.LookupDispatchAction.getMethodName(LookupDispatchAction.java:271)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:173)
org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:150)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:46)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
我把資源文件換了英文,結果一樣。還是同樣錯誤。。資源文件我的經過編碼轉換應該也沒什麽問題
。。迷惑中
LZ,建议你先换换环境,休息一下然后再从头仔仔细细的检查一遍所有的地方,看看是不是哪里写错了,struts1的配置应该是很简单的呀,思路也好清晰的,再好好看看吧
讓query方法運行然後查詢出數據成功加載頁面