------------------------------------------STRUTS.xml<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- START SNIPPET: xworkSample -->
<struts>
<constant name="struts.objectFactory" value="spring"></constant>
<constant name="struts.i18n.encoding" value="GBK"/>
<package name="ssh" extends="struts-default" >
<global-results>
<!-- 下面定义的结果对所有的Action都有效 -->
<result name="exception">/error.jsp</result>
</global-results> <global-exception-mappings>
<!-- 指Action抛出Exception异常时,转入名为exception的结果。 -->
<exception-mapping exception="java.lang.Exception" result="exception"/>
</global-exception-mappings> <action name="listbook" class="listbean" method="ListBook">
<result name="success">/index.jsp</result>
</action>
<action name="updatebook" class="updatebean" method="UpdateBook">
<result name="success">/index.jsp</result>
</action>
<action name="addbook" class="addbean" method="AddBook">
<result name="success">/index.jsp</result>
</action>
<action name="getbook" class="getbean" method="GetBook">
<result name="success">/index.jsp</result>
</action>
<action name="delbook" class="delbean" method="DeleteBook">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unable to instantiate Action, listbean, defined for 'listbook' in namespace '/'Error creating bean with name 'listbean' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [ssh.hbl.service.impl.BookService] for property 'bookservice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [ssh.hbl.service.impl.BookService] for property 'bookservice': no matching editors or conversion strategy found - action - file:/E:/Program%20Files/Tomcat%206.0/webapps/ssh/WEB-INF/classes/struts.xml:21:68
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
root cause Unable to instantiate Action, listbean, defined for 'listbook' in namespace '/'Error creating bean with name 'listbean' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [ssh.hbl.service.impl.BookService] for property 'bookservice'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [ssh.hbl.service.impl.BookService] for property 'bookservice': no matching editors or conversion strategy found - action - file:/E:/Program%20Files/Tomcat%206.0/webapps/ssh/WEB-INF/classes/struts.xml:21:68
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:294)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
你把java代码贴上来看下
import java.util.List;import ssh.hbl.model.Book;
import ssh.hbl.service.impl.BookService;import com.opensymphony.xwork2.ActionSupport;public class bookAction extends ActionSupport {
private BookService bookservice;
public String ListBook()
{
List<Book> list=bookservice.listBook();
//for(Iterator it=list.iterator();)
for (Iterator it=list.iterator();it.hasNext();)
{
Book b=(Book)it.next();
System.out.println("result="+b.getBookid()+"---"+b.getBookname()+"---"+b.getAuthor());
}
return "success";
}
public String GetBook()
{
Book b=bookservice.getBook(14);
System.out.println("result="+b.getBookid()+"---"+b.getBookname()+"---"+b.getAuthor());
return "success";
}
public String UpdateBook()
{ System.out.println("更新成功");
return "success";
}
public String DeleteBook()
{
bookservice.delBook(14);
return "success";
}
public String AddBook()
{
Book b=new Book();
b.setBookid(59);
b.setAuthor("hbl");
b.setBookname("hbl");
b.setPrice("hbl");
bookservice.updateBook(b);
return "success";
}
public BookService getBookservice() {
return bookservice;
}
public void setBookservice(BookService bookservice) {
this.bookservice = bookservice;
}
}
import java.util.List;import ssh.hbl.model.Book;
import ssh.hbl.service.impl.BookService;import com.opensymphony.xwork2.ActionSupport;public class bookAction extends ActionSupport {
private BookService bookservice;
public String ListBook()
{
List<Book> list=bookservice.listBook();
//for(Iterator it=list.iterator();)
for (Iterator it=list.iterator();it.hasNext();)
{
Book b=(Book)it.next();
System.out.println("result="+b.getBookid()+"---"+b.getBookname()+"---"+b.getAuthor());
}
return "success";
}
public String GetBook()
{
Book b=bookservice.getBook(14);
System.out.println("result="+b.getBookid()+"---"+b.getBookname()+"---"+b.getAuthor());
return "success";
}
public String UpdateBook()
{
Book b=new Book();
b.setBookid(14);
b.setAuthor("hbl");
b.setBookname("hbl");
b.setPrice("hbl");
bookservice.updateBook(b);
return "success";
}
public String DeleteBook()
{
bookservice.delBook(14);
return "success";
}
public String AddBook()
{
Book b=new Book();
b.setAuthor("hbl");
b.setBookname("hbl");
b.setPrice("123");
bookservice.addBook(b);
return "success";
}
public BookService getBookservice() {
return bookservice;
}
public void setBookservice(BookService bookservice) {
this.bookservice = bookservice;
}
}