小弟用struts 2开发 遇到个奇怪的问题
JSP页面<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="font1"></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
</table>
<div class="doubleselect">
<s:form name="s" action="member_add" method="post">
<table width="98%" border="0" align="center" cellpadding="5"cellspacing="1" bgcolor="#AED2F6" class="font1">
<tr>
<td align="center" colspan="2" bgcolor="#BDDAF8" class="font1">
兴动卡信息录入
</td>
</tr>
<tr>
<td bgcolor="#F1F7FD">
<s:doubleselect doubleList="#request.listMap.get(top)" list="#request.clist" doubleName="month" name="year"
doubleHeaderValue="请选择月份" headerValue="请选择年份" label="数据月份"></s:doubleselect>
</td>
</tr>
<tr>
<td bgcolor="#BDDAF8">
文档上传:
</td>
<td align="left" bgcolor="#F1F7FD">
<input name="xls" type="file" class="box3"></input>
<font color="red">*仅限excel</font>
</td>
</tr>
<tr>
<td height="30" colspan="2" align="center" bgcolor="#FFFFFF">
<input name="Submit43" type="submit" class="btn01" value="提 交"
onMouseOut="this.className='btn01'"onMouseOver="this.className='btn02'" onclick="return check();">
<input name="Submit432" type="button" class="btn01" value="返 回"
onMouseOut="this.className='btn01'"onMouseOver="this.className='btn02'"onClick="javascript:history.back();">
</td>
</tr>
</table>
<div style="”color: red”">
<s:fielderror />
</div>
</s:form>
</div>
<script> function check()
{
if(s.xls.value.length<1)
{
alert('请上传文件');
return false;
}
}
</script>
</body>struts.xml文件<struts>
<constant name="struts.i18n.encoding" value="gb2312"></constant>
<constant name="struts.devMode" value="true" />
<constant name="struts.multipart.saveDir" value="D:\temp\"></constant>
<constant name="struts.multipart.maxSize" value="1073741824" /><package name="sportsclub" extends="struts-default" namespace="/">
<action name="member_*" class="com.sports.club.action.MemberAction" method="{1}">
<result>/admin/member_{1}.jsp</result>
<result name="toAdd">/admin/member_add.jsp</result>
<result name="add">/admin/member_add_success.jsp</result>
</action>
</package>
</struts>MemberAction.javapublic class MemberAction extends ActionSupport { /**
*
*/
private static final long serialVersionUID = 1L;
private String year;
private String month;
private List list=new ArrayList();
private File xls;
private String xlsFileName;
HttpServletRequest request=ServletActionContext.getRequest();
public String add(){
System.out.println(xls);
try {
FileInputStream is = new FileInputStream(xls);
String url="admin/membercard/"+xlsFileName;//数据中的地址
String realpath=request.getRealPath("/"+url);
FileOutputStream os = new FileOutputStream(realpath);
System.out.println(realpath);
byte[] buffer = new byte[40000];
int length =0;
while((length=is.read(buffer))>0)
{
os.write(buffer,0, length);
}
is.close();
os.close();
Input in = new Input();
in.input(realpath,month,year);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "add";
}
谁能告诉我 为什么会是No result defined for action com.sports.club.action.MemberAction and result input
明明有return啊 我把 add()方法去掉 就报错是No such method 说明读到了action的 add方法
跪求解决方法
JSP页面<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="font1"></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
</table>
<div class="doubleselect">
<s:form name="s" action="member_add" method="post">
<table width="98%" border="0" align="center" cellpadding="5"cellspacing="1" bgcolor="#AED2F6" class="font1">
<tr>
<td align="center" colspan="2" bgcolor="#BDDAF8" class="font1">
兴动卡信息录入
</td>
</tr>
<tr>
<td bgcolor="#F1F7FD">
<s:doubleselect doubleList="#request.listMap.get(top)" list="#request.clist" doubleName="month" name="year"
doubleHeaderValue="请选择月份" headerValue="请选择年份" label="数据月份"></s:doubleselect>
</td>
</tr>
<tr>
<td bgcolor="#BDDAF8">
文档上传:
</td>
<td align="left" bgcolor="#F1F7FD">
<input name="xls" type="file" class="box3"></input>
<font color="red">*仅限excel</font>
</td>
</tr>
<tr>
<td height="30" colspan="2" align="center" bgcolor="#FFFFFF">
<input name="Submit43" type="submit" class="btn01" value="提 交"
onMouseOut="this.className='btn01'"onMouseOver="this.className='btn02'" onclick="return check();">
<input name="Submit432" type="button" class="btn01" value="返 回"
onMouseOut="this.className='btn01'"onMouseOver="this.className='btn02'"onClick="javascript:history.back();">
</td>
</tr>
</table>
<div style="”color: red”">
<s:fielderror />
</div>
</s:form>
</div>
<script> function check()
{
if(s.xls.value.length<1)
{
alert('请上传文件');
return false;
}
}
</script>
</body>struts.xml文件<struts>
<constant name="struts.i18n.encoding" value="gb2312"></constant>
<constant name="struts.devMode" value="true" />
<constant name="struts.multipart.saveDir" value="D:\temp\"></constant>
<constant name="struts.multipart.maxSize" value="1073741824" /><package name="sportsclub" extends="struts-default" namespace="/">
<action name="member_*" class="com.sports.club.action.MemberAction" method="{1}">
<result>/admin/member_{1}.jsp</result>
<result name="toAdd">/admin/member_add.jsp</result>
<result name="add">/admin/member_add_success.jsp</result>
</action>
</package>
</struts>MemberAction.javapublic class MemberAction extends ActionSupport { /**
*
*/
private static final long serialVersionUID = 1L;
private String year;
private String month;
private List list=new ArrayList();
private File xls;
private String xlsFileName;
HttpServletRequest request=ServletActionContext.getRequest();
public String add(){
System.out.println(xls);
try {
FileInputStream is = new FileInputStream(xls);
String url="admin/membercard/"+xlsFileName;//数据中的地址
String realpath=request.getRealPath("/"+url);
FileOutputStream os = new FileOutputStream(realpath);
System.out.println(realpath);
byte[] buffer = new byte[40000];
int length =0;
while((length=is.read(buffer))>0)
{
os.write(buffer,0, length);
}
is.close();
os.close();
Input in = new Input();
in.input(realpath,month,year);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "add";
}
谁能告诉我 为什么会是No result defined for action com.sports.club.action.MemberAction and result input
明明有return啊 我把 add()方法去掉 就报错是No such method 说明读到了action的 add方法
跪求解决方法
解决方案 »
- 求救hibernate报Illegal attempt to associate a collection with
- Servlet取得页面参数为何为空
- 求一个算法,要求高效
- 关于hibernate的问题
- 将数据库里的东西用图形的方式表示出来,柱形图也好,波浪图也好~
- 我web报异常:ServletException in '': Response already committed.
- 在window2003下 JSP连接sql server 出现的错误
- tomcat4.1.24的session问题,session中的javabean自动消失
- Method does no return a value at line 。。写类时碰到的麻烦,请帮忙啊
- 我使用jbuilder6.0来开发jsp,出现乱码怎么办????急急急!
- struts2.1.6 datetimepicker 组件月份乱码问题
- Connection能设置成静态的吗
为什么不指定方法名?
action name="member_*" ? 这命名规范
private String xlsFileName;
struts2上传文件还需要一个参数
private String xlsContentType;
以及他们的setter方法;LZ的出问题是因为struts2在传递参数时出错了,因此Add()方法并没有执行
直接返回了input,而LZ又没定义input视图所以No result defined for action com.sports.club.action.MemberAction and result input