标签:extend catch 简单 逻辑 res 导入jar包 tac blog com
2、编写业务逻辑类
package com.chen.rest; import org.restlet.resource.Get; import org.restlet.resource.ServerResource; /** * @author chenjie * @version 1.0 * @since 2017-02-08 */ public class HelloWorld extends ServerResource { @Get public String represent() { return "hello world!"; } }
package com.chen.rest; import org.restlet.Application; import org.restlet.Restlet; import org.restlet.routing.Router; /** * @author chenjie * @version 1.0 * @since 2017-02-08 */ public class FirstApp extends Application { @Override public synchronized Restlet createInboundRoot() { System.out.println("1111111111"); Router router = new Router(getContext()); router.attach("/hello",HelloWorld.class); return router; } }
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>first steps servlet</display-name> <!-- Restlet adapter --> <servlet> <servlet-name>RestletServlet</servlet-name> <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class> <init-param> <!-- Application class name --> <param-name>org.restlet.application</param-name> <param-value>com.chen.rest.FirstApp</param-value> </init-param> </servlet> <!-- Catch all requests --> <servlet-mapping> <servlet-name>RestletServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
标签:extend catch 简单 逻辑 res 导入jar包 tac blog com
原文地址:http://www.cnblogs.com/chenjack/p/6379166.html