yanjianpeng_2018
2019-08-29 11:52
采纳率: 100%
浏览 1.1k
已采纳

web.xml 转换成 springboot配置问题 一直没有成功

    <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>org.activiti.rest.explorer.application.ExplorerRestApplication</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>RestletServlet</servlet-name>
        <url-pattern>/bpm/service/*</url-pattern>
    </servlet-mapping>
1.4.1.RELEASE springboot版本

怎么转换  ...
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

  • 潇潇兮~平 2019-08-29 16:04
    最佳回答
    @ServletComponentScan
    public class MyspringbootApplication extends SpringBootServletInitializer {
    
    
        public static void main(String[] args) {
            SpringApplication.run(MyspringbootApplication.class, args);
        }
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(MyspringbootApplication.class);
        }
    
        @Bean
        public ServletRegistrationBean servletRegistrationBean() {
            return new ServletRegistrationBean(new MyServlet1(), "/service/*");
        }
    
    }
    
    @WebServlet(urlPatterns = "/service/*",initParams={@WebInitParam(name="org.restlet.application", value="com.anfae.admin.common.bpm.web.ExplorerRestApplication")})
    public class MyServlet1 extends ServerServlet {
    
        private static final long serialVersionUID = 1L;
    }
    
    public class ExplorerRestApplication extends ActivitiRestApplication {
    
        public ExplorerRestApplication() {
            super();
        }
    
        @Override
        public synchronized Restlet createInboundRoot() {
            Router router = new Router(getContext());
            router.attachDefault(DefaultResource.class);
            ModelerServicesInit.attachResources(router);
            DiagramServicesInit.attachResources(router);
            JsonpFilter jsonpFilter = new JsonpFilter(getContext());
            jsonpFilter.setNext(router);
            return jsonpFilter;
        }
    
    评论
    解决 无用
    打赏 举报
查看更多回答(3条)

相关推荐 更多相似问题