mvn archetype:generate -DgroupId=com.example -DartifactId=webapp -DarchetypeArtifactId=maven-archetype-webapp <dependency> <groupId>com.github.osgi- enroute</groupId> <artifactId>osgi.enroute.pagedown</artifactId> <version>2.0.0</version> </dependency> import org.osgi.service.component.annotations.Component; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import java.io.IOException; import java.io.PrintWriter; @Component(service = Servlet.class, property = {"alias=/markdown"}) public class MarkdownResource implements Servlet { @Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { PrintWriter writer = res.getWriter(); writer.println("<html><body>"); writer.println("<h1>OSGi Enroute PageDown WebResource</h1>"); writer.println("<textarea id=\"markdown\" rows=\"10\" cols=\"50\"></textarea>"); writer.println("<div id=\"preview\"></div>"); writer.println("<script src=\"https://raw.githubusercontent.com/osgi/osgi.enroute.site/master/content/js/pagedown/Markdown.Converter.js\"></script>"); writer.println("<script src=\"https://raw.githubusercontent.com/osgi/osgi.enroute.site/master/content/js/pagedown/Markdown.Sanitizer.js\"></script>"); writer.println("<script src=\"https://raw.githubusercontent.com/osgi/osgi.enroute.site/master/content/js/pagedown/Markdown.Editor.js\"></script>"); writer.println("<script>"); writer.println("var converter = new Markdown.Converter();"); writer.println("var editor = new Markdown.Editor(converter);"); writer.println("editor.run();"); writer.println("</script>"); writer.println("</body></html>"); } } Private-Package: com.example Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=11))" mvn clean install mvn jetty:run


上一篇:
下一篇:
切换中文