yanjianpeng_2018
yanjianpeng_2018
采纳率41.7%
2019-08-29 11:52

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

5
已采纳
    <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条回答

  • meiguang_2019 潇潇兮~平 2年前
    @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;
        }
    
    点赞 评论 复制链接分享
  • yanjianpeng_2018 yanjianpeng_2018 2年前

    图片说明

    图片说明

    那个有编译异常呀,位置是对的吧

    点赞 评论 复制链接分享
  • guangcaiwudong Kevin.Y.K 2年前
    //spring boot 2.x
    @Bean
    public ServletRegistrationBean<ServerServlet> restletServlet() {
            ServletRegistrationBean<ServerServlet> bean = new ServletRegistrationBean<>(new ServerServlet(), "/bpm/service/*");
            bean.setName("restletServlet");
            return bean;
    }
    
    //spring boot 1.x
    @Bean
    public ServletRegistrationBean restletServlet() {
            ServletRegistrationBean bean = new ServletRegistrationBean(new ServerServlet(), "/bpm/service/*");
            bean.setName("restletServlet");
            return bean;
    }
    
    点赞 评论 复制链接分享
  • yyjjttww yyjjttww 2年前

相关推荐