2 qq 20265187 qq_20265187 于 2016.03.10 21:24 提问

struts2跳转,出错,是action无法加载跳转吗

图片说明
错误信息是这个

我的action中这样写的


        <!-- 增加学生的方法 -->
        <action name="addStudentAction" class="addStudentAction" method="addStudentAction">
            <result name="success" type="redirect">student.jsp</result>
            <result name="error">error.jsp</result>
        </action>

action代码这样的

 package com.yzj.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;
import com.yzj.model.Student;
import com.yzj.service.StudentService;

@Component("studentAction")
@Scope("prototype")
public class StudentAction  extends ActionSupport {
    HttpServletRequest request;
    private StudentService studentService;
    private String username;
    private List<Student> student;
    private Student stu;


    public Student getStu() {
        return stu;
    }
    public void setStu(Student stu) {
        this.stu = stu;
    }
    public HttpServletRequest getRequest() {
        return request;
    }
    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public List<Student> getStudent() {
        return student;
    }
    public void setStudent(List<Student> student) {
        this.student = student;
    }
    public StudentService getStudentService() {
        return studentService;
    }
    public void setStudentService(StudentService studentService) {
        this.studentService = studentService;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }


    public String findAllStudent() {
        System.out.println("000000000000000");
        student = studentService.findAllStudent();
        System.out.println("111111111111111111");
        if (student != null && student.size() > 0 ) {

            return "success";
        }
        return "error";
    }
}

不知道怎么回事,求大神!!

7个回答

jiar2046
jiar2046   2016.03.10 21:30

配置action的class应该是完整的类名。

u013772876
u013772876   2016.03.10 21:35


你这样配置没报错吗? class应该是配置你映射的类路径吧

enpterexpress
enpterexpress   2016.03.10 22:40

类名写错了

u013829202
u013829202   Rxr 2016.03.11 09:33

配置action的class错了。一个打酱油路过的围观群众

wonezm
wonezm   2016.03.11 09:56

应该加上class域名

Royal_lr
Royal_lr   Ds   Rxr 2016.03.11 14:30

你这样的话,struts的action要交给spring管理,,看下你的spring配置文件怎么写的

chen18677338530
chen18677338530   2016.03.11 18:25

是spring的问题

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!