[b] FYI: Just using resteasy to access the service layer, which returns xml, then using xslt to translate it for view. But... issues below
If you can fix it, pls let me known kindly. Regards!
[/b]
[align=center][img]http://dl.iteye.com/upload/picture/pic/126617/34d63678-14ad-332d-8c8b-3eba82d173bb.png[/img][/align]
[color=blue]
web.xml[/color]
[color=blue]
Bean in applicationContext.xml[/color]
[color=blue] The test page[/color]
[color=blue] BookService[/color]
[color=blue] BookServiceImpl [/color]
If you can fix it, pls let me known kindly. Regards!
[/b]
[align=center][img]http://dl.iteye.com/upload/picture/pic/126617/34d63678-14ad-332d-8c8b-3eba82d173bb.png[/img][/align]
[color=blue]
web.xml[/color]
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!--
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>com.eric.bms.service.BookService</param-value>
</context-param>
-->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/resource</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>ContextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/resource/*</url-pattern>
</servlet-mapping>
</web-app>
[color=blue]
Bean in applicationContext.xml[/color]
<bean id="bookDao" class="com.eric.bms.dao.impl.BookDaoImpl" autowire="byName"/>
<bean id="bookService" class="com.eric.bms.service.impl.BookServiceImpl" autowire="byName"/>
[color=blue] The test page[/color]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Show all the books here</title>
<%String path = request.getContextPath(); %>
<script src="<%=path %>/js/book.js" type="text/javascript"></script>
</head>
<body onload='display("<%=path %>/resource/bs/list", "<%=path %>/xsl/bsummary.xsl", "books")'>
<div id="books" align="center"></div>
</body>
</html>
[color=blue] BookService[/color]
@Path("bs")
public interface BookService {
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("/list/")
BookSummary list();
}
[color=blue] BookServiceImpl [/color]
public class BookServiceImpl implements BookService {
private BookDao bookDao;
public BookSummary list() {
BookSummary summary = new BookSummary();
List<Book> list = bookDao.getAll();
for(Book book : list) {
summary.getList().add(book);
}
return summary;
}
}