我难道那里写错了吗?

Gemerl 2013-06-30 11:39:15
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>



html:

<h3>上传文件</h3>
<form action="photoAction.action" method="post" enctype="application/x-www-form-urlencoded">
<input type="file" name="photo" /><br/>
<input type="submit" value="提交"/>
</form>

action:

import com.jspsmart.upload.File;
import com.opensymphony.xwork2.ActionSupport;

public class PhotoAction extends ActionSupport{
private File photo;

public File getPhoto() {
return photo;
}

public void setPhoto(File photo) {
this.photo = photo;
}

@Override
public String execute() throws Exception {
System.out.println(photo);
System.out.println(photo.getFilePathName());
return SUCCESS;
}
}

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<constant name="struts.devMode" value="true" /> <!--开发模式无需重启服务器-->
<constant name="struts.ui.theme" value="simple" /> <!--//<S:>标签简单风格-->

<package name="default" namespace="/" extends="struts-default">


<action name="photoAction" class="com.action.PhotoAction">
<result>success.jsp</result>
</action>
</package>

</struts>

jar:
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang3-3.1.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
jspsmartupload.jar
ognl-3.0.5.jar
struts2-core-2.3.3.jar
xwork-core-2.3.3.jar

为什么一直报错:No result defined for action com.action.PhotoAction and result input
...全文
282 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZHOU西口 2013-07-01
  • 打赏
  • 举报
回复
你的问题是不是photo是空的,报空指针?
文森特先森 2013-06-30
  • 打赏
  • 举报
回复


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
    <constant name="struts.devMode" value="true" />	<!--开发模式无需重启服务器-->
    <constant name="struts.ui.theme" value="simple" />  <!--//<S:>标签简单风格-->
      
    <package name="default" namespace="/" extends="struts-default">
		
		
		<action name="photoAction" class="com.action.PhotoAction">
		    <result>success.jsp</result>
                    <interceptor-ref name="defaultStack" />
		</action>
    </package>

</struts>
JAVA_单线程 2013-06-30
  • 打赏
  • 举报
回复
<result>/success.jsp</result>
侠龙 2013-06-30
  • 打赏
  • 举报
回复
少了应该还要配置一个struts2自带的文件上传拦截器,叫fileupload
partys 2013-06-30
  • 打赏
  • 举报
回复
<result name="success">success.jsp</result> success.jsp也应该是相对路径

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧