
笔者的代码很简单,平常的配置文件,web.xml如下
<servlet>
<!--名称 -->
<servlet-name>springmvc</servlet-name>
<!-- Servlet类 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<!--SpringMVC配置参数文件的位置 -->
<param-name>contextConfigLocation</param-name>
<!--默认名称为ServletName-servlet.xml -->
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>
<!-- 启动顺序,数字越小,启动越早 -->
<load-on-startup>1</load-on-startup>
</servlet> <!--所有请求都会被springmvc拦截 -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/frontend/*</url-pattern>
</servlet-mapping>
myeclipse开发项目,按照常规方法右键项目 Export-->jar却不能执行。
网上说注解的@Controller不能在jar中工作,后来在*找到了答案:
Spring Annotation-based controllers not working if it is inside jar file
解决方法:导出jar文件时勾选下面的:Add directory entries复选框
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 will solve the problem.
其他参考信息:
why spring mvc not able to read URL from controller class kept in jar file