spring + Embedded jetty + <web-app> how to create context -


there maven-project, /web-inf/web.xml :

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  version="2.5">  <servlet> <servlet-name>basewebapp</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param>     <param-name>contextconfiglocation</param-name>     <param-value>/web-inf/applicationcontext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>basewebapp</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> 

and applicationcontext.xml :

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p"           xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd                     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd                     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd                     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">         <import resource="classpath:datasource.xml"/>         <mvc:annotation-driven/>        <context:component-scan base-package="com.blogspot.permgen.webapp"/>         <mvc:resources mapping="/resources/**" location="/resources/"/>         <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"              p:prefix="/web-inf/pages/"          p:suffix=".jsp"/> </beans> 

the controller based oh annotations.

when launched mvn -djetty.port=9999 jetty:run applicaton starts well. decided initialize jetty in code, failed create context it. here main class:

public class appmain { public static void main(string[] args) throws exception {      servletcontexthandler sch = new servletcontexthandler();  /*here must context initialization ... */      server jetty = new server(9999);     jetty.sethandler(sch);     jetty.start(); } } 

so question is: how init context jetty web.xml ?
possible @ all, or have parse somehow using of spring?

if want use web.xml configure context, don't use servletcontexthandler, instead use webappcontext, derived servletcontexthander , adds ability use web.xml configure itself.

here example: https://www.eclipse.org/jetty/documentation/current/embedded-examples.html#embedded-one-webapp


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -