我几个小时以来一直在阅读与此主题相关的所有问题,但我没有找到解决问题的方法。我的春季版本是4.2.1版本。
<div class="row fluid">
<div class="col-md-3 clearfix">
<img src="img">
<div class="img-text">
Tekst fdskfjsdghdfn ufghdg ufdhs gdfksjhg
jfdksgbfjdsk gfd jgbdfjhg dfkjhg fidughdf kjvhdf ugdfh
</div>
</div>
<div class="col-md-3 clearfix">
<img src="img">
<div class="img-text">
Tekst fdskfjsdghdfn ufghdg ufdhs gdfksjhg
jfdksgbfjdsk gfd jgbdfjhg dfkjhg fidughdf kjvhdf ugdfh
</div>
</div>
<div class="col-md-3 clearfix">
<img src="img">
<div class="img-text">
Tekst fdskfjsdghdfn ufghdg ufdhs gdfksjhg
jfdksgbfjdsk gfd jgbdfjhg dfkjhg fidughdf kjvhdf ugdfh
</div>
</div>
<div class="col-md-3 clearfix">
<img src="img">
<div class="img-text">
Tekst fdskfjsdghdfn ufghdg ufdhs gdfksjhg
jfdksgbfjdsk gfd jgbdfjhg dfkjhg fidughdf kjvhdf ugdfh
</div>
</div>
</div>
...
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/security.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
...
<mvc:resources mapping="/lib/**" location="/lib/"/>
<mvc:resources mapping="/img/**" location="/img/" />
<mvc:resources mapping="/app/**" location="/app/" />
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:annotation-driven />
<context:annotation-config />
<context:component-scan base-package="com.my.controller" />
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/myview/"
p:suffix=".jsp" />
我希望我的控制器位于我的应用程序的根目录中(localhost:8084 / MyApp /)。我的IndexController工作正常,但我的资源没有! 例如,当我请求图像(localhost:8084 / MyApp / img / img.png)时,我遇到了这个错误:
@Controller
public class IndexController {
@RequestMapping(value="/",method = RequestMethod.GET)
public String index(HttpServletRequest request, Model map) {
return "index";
}
}
有根本原因:
HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: No matching constant for [0]
答案 0 :(得分:0)