---
title: "Need Help! Issues in resteasy & spring"
author: "eric2500"
date: "2013-07-14T04:20:40Z"
tags: []
categories: ["编程语言"]
slug: "need-help-issues-in-resteasy-spring"
draft: false
lastmod: "2013-07-14T04:31:10Z"
id: 1905575
url: "https://eric2500.iteye.com/blog/1905575"
---

**    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!
**

![](http://dl.iteye.com/upload/picture/pic/126617/34d63678-14ad-332d-8c8b-3eba82d173bb.png)
<span style="color:blue">
    web.xml</span>

```java

<!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>

```

<span style="color:blue">
    Bean in applicationContext.xml</span>

```java

	<bean id="bookDao" class="com.eric.bms.dao.impl.BookDaoImpl" autowire="byName"/>
	<bean id="bookService" class="com.eric.bms.service.impl.BookServiceImpl" autowire="byName"/>

```

<span style="color:blue">    The test page</span>

```java

<%@ 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>

```

<span style="color:blue">    BookService</span>

```java

@Path("bs")
public interface BookService {

	@GET
	@Produces(MediaType.APPLICATION_XML)
	@Path("/list/")
	BookSummary list();
	
}

```

<span style="color:blue">    BookServiceImpl </span>

```java

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;
	}

}

```