日期:2014-05-17 浏览次数:20616 次
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import org.codehaus.jettison.json.JSONObject;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
@Path("/helloWorld")
public class HelloWorld {
@GET
// @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Object helloWorld(@QueryParam("from")String fromValue, @QueryParam("avc")String avc){
return fromValue;
}
}
@Entity
@XmlRootElement(name = "Project")
@XmlAccessorType(XmlAccessType.FIELD)
public class Project extends VersionedEntity {
private static final long serialVersionUID = 1L;
/** ID */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@FormParam("id")
@XmlAttribute
private Long id;
/** 名称 */
@FormParam("name")
@XmlAttribute
private String name;
/** 投资方/建设单位 */
@FormParam("investor")
@XmlAttribute
private String investor;
.....
@Controller
@Path("project")
public class ProjectController{
private static final Logger LOGGER = LoggerFactory.getLogger(ProjectController.class);
@Resource(name = "projectServiceImpl")
private ProjectService projectService;
@GET
@Path("list")
public ModelAndView toProject(){
return new ModelAndView("/static/project/list");
}
@GET
@Path("{id}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})