login.jsp页面  <body>
    <form action="login" method="post">
    username:<input type="text" name="username"><br/>
    password:<input type="password" name="password"><br/>
    <input type="submit" value="submit">
  </body>
struts.xml页面<package name="zhou" extends="struts-default">
<action name="login" class="ac.LoginAction">
<result name="success">/upload.jsp</result>
<result name="input">/index.jsp</result></action>
<action name="upload" class="ac.FileUploadAction">
<param name="savePath">/upload</param>
<result name="success">/show.jsp</result>
<result name="input">/upload.jsp</result></action></package>login.action页面package ac;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Map;import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

public String execute() throws Exception {
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession(); String url = "jdbc:mysql://localhost:3306/";
String dbName = "zt";
String driverName = "com.mysql.jdbc.Driver";
String userName = "root";
String passWord = "123"; Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName(driverName).newInstance();
con = DriverManager.getConnection(url + dbName, userName, passWord);
stmt = con.createStatement(); } catch (Exception e) {
System.out.println(e.getMessage());
}
stmt = con.createStatement();
String sql = "select * from user where username='" + this.username
+ "'and password='" + this.password + "'";
rs = stmt.executeQuery(sql); if (!rs.next()) { return INPUT;
} else {
session.put("USER", this.username);
return SUCCESS; }




}}
upload.jsp
  <body>
    <s:form action="upload" method="post" enctype="multipart/form-data">
    <s:file name="imgfile" label="选择图片"></s:file>
    <s:text name="title"></s:text>
    <s:submit value="submit"/>
    
    
    
    </s:form>
  </body>FileUploadAction页面package ac;import com.opensymphony.xwork2.ActionSupport;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import   java.text.SimpleDateFormat;
import java.util.Date;
import java.sql.*;import org.apache.struts2.ServletActionContext;public class FileUploadAction extends ActionSupport {
private String title;
private File imgfile;
private static final int BUFFER_SIZE=16*1024;
private String contentType;
private String fileName;
private String savePath;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public File getImgfile() {
return imgfile;
}
public void setImgfile(File imgfile) {
this.imgfile = imgfile;
}
public String getContentType() {
return contentType;
}
public void setImgfileContentType(String contentType) {
this.contentType = contentType;
}
public String getFileName() {
return fileName;
}
public void setImgfileFileName(String fileName) {
this.fileName = fileName;
}
public String getSavePath() {
return ServletActionContext.getServletContext().getRealPath("/")+savePath;
}
public void setSavePath(String savePath) {
this.savePath = savePath;
}
public String execute() throws Exception{
FileInputStream fin=new FileInputStream(getImgfile()); FileOutputStream fout=new FileOutputStream(getSavePath()+"//"+getFileName());
byte[] buffer=new byte[BUFFER_SIZE];
int len=0;
while((len=fin.read(buffer))>0){
fout.write(buffer,0,len);
SimpleDateFormat   formatter   =   new   SimpleDateFormat   ("yyyy年MM月dd日   HH:mm:ss     ");     
 Date   curDate   =   new  Date(System.currentTimeMillis());//获取当前时间     
String   time   =   formatter.format(curDate); 
System.out.println(time);

//插入数据库
String url = "jdbc:mysql://localhost:3306/";
String dbName = "zt";
String driverName = "com.mysql.jdbc.Driver";
String userName = "root";
String passWord = "123";

 Connection con = null;
Statement stmt = null;
try {
Class.forName(driverName).newInstance();
con = DriverManager.getConnection(url + dbName, userName, passWord);
stmt = con.createStatement(); } catch (Exception e) {
System.out.println(e.getMessage());
}
stmt = con.createStatement();
int val=stmt.executeUpdate("insert sinfor(fileName,time) values('"+fileName+"','"+time+"')");
if (val == 0) {
return INPUT;
} else { return SUCCESS;
}










//插入数据库








}

return INPUT;





}



}
错误描述Could not find action or result
There is no Action mapped for namespace /upload and action name . - [unknown location]

解决方案 »

  1.   

    你的报错信息很明显 没有对应的action  我觉得你的配置文件有点问题 好好看看  根据报错信息走 
      

  2.   

    如果真的是这种低级错误的话 我就不烦劳各位了  如果大家真心帮我 请大家认真看一下好吧 旁观者清不是吗? 你们知道了请指教 你们也没有找到的话就别再这说了 这个错误烦了我三天了 再在这听你们在这说这些没有用的话 我英语也没有差到那种地步我知道是没有找到action 但是为神马直接从upload.jsp中就能上传 而登陆后就不能那 摆脱大家认真点好吧  如果大家只是想刷分的话 如果问题解决了我再发个帖子直接给分行吗???!!!!!!!!!!!!!
      

  3.   

    看你贴出来的代码是对的,debug调试一吧
      

  4.   

     <s:form action="upload.action" method="post" enctype="multipart/form-data">
      <s:file name="imgfile" label="选择图片"></s:file>
      <s:text name="title"></s:text>
      <s:submit value="submit"/>
        
      </s:form>