日期:2014-05-17 浏览次数:20927 次
<form id="mainform2">
<input type="button" id="testButton" value="查询所有用户" onclick="test()">
<script type="text/javascript">
function test(){
document.getElementById("mainform2").action = "testSearchUser";
document.getElementById("mainform2").submit();
}
</script>
</form>
public class TestUserAction extends BaseAction{
@Resource
private StudentService studentService;
@Action(value="/testSearchUser",results={@Result(name="success",location="/pages/jsp/testSearchUser.jsp"),@Result (name = "error",location = "/pages/jsp/error.jsp")})
public String testSearchUser(){
List<StudentDto> studentList = studentService.studentlistsAll();
System.out.println(studentList);
return SUCCESS;
}
public StudentService getStudentService() {
return studentService;
}
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
}
@Service
public class StudentService {
@Resource
private StudentMapper studentMapper;
public List<StudentDto> studentlistsAll(){
return studentMapper.studentlistsAll();
}
}
@SqlMapper
public interface StudentMapper {
@Select("select * from student")
public List <StudentDto> studentlistsAll();
}
<context:annotation-config />
<context:component-scan base-package="cn.com.softwise" />
2014-1-13 15:30:29 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [cn.com.softwise.wjf.dao.StudentMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}
No ma