The author of the code is very simple, the usual configuration file, Web. Xml as follows
<servlet> <!--name - <Servlet-name>Springmvc</Servlet-name> <!--servlet class - <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class> <Init-param> <!--SPRINGMVC location of configuration parameter files - <Param-name>Contextconfiglocation</Param-name> <!--The default name is Servletname-servlet.xml - <Param-value>Classpath*:springmvc-servlet.xml</Param-value> </Init-param> <!--start sequence, the smaller the number, the earlier the start - <Load-on-startup>1</Load-on-startup> </servlet> <!--all requests will be intercepted by Springmvc . - <servlet-mapping> <Servlet-name>Springmvc</Servlet-name> <Url-pattern>/frontend/*</Url-pattern> </servlet-mapping>
MyEclipse development project, according to the normal method right-click Project Export-->jar but cannot execute.
The @controller on the web said the annotations could not work in jars, and later found the answer in StackOverflow:
Spring annotation-based Controllers not working if it is inside Jar file
Workaround: When exporting the jar file, tick the following: Add directory entries check box
When you export the jar file using the Export utility in eclipse there is a option called Add directory entries. Check this option and export the jar file, this would solve the problem.
Additional reference information:
Why spring MVC isn't able to the read URL from the controller class kept in jar file
@Controller not working while packaged in external jar
Spring MVC Project Export jar package does not recognize normal mapping issues