【发布时间】:2016-09-26 09:52:21
【问题描述】:
我在类级别为某些视图 (jsp) 添加了 @RequestMapping 注释。当我尝试使用正确的 URL 映射访问这些页面时,页面显示但无法正确呈现,并且无法加载 .js 和 .css 文件。在浏览器中,我得到以下错误。 GET 404(未找到) 在服务器日志中,我收到以下消息。 org.springframework.web.servlet.PageNotFound noHandlerFound 警告:在名称为“spring-dispatcher”的 DispatcherServlet 中找不到具有 URI [/ccb/invoice/webjars/adminlte/2.3.3/plugins/iCheck/icheck.min.js] 的 HTTP 请求的映射。 虽然 Servlet 配置文件中的静态资源映射非常好,并且对于那些在类级别没有 @requstmapping 注释的页面加载它,但不确定为什么事情会发生变化。
你能告诉我我哪里出错了。
@Controller @RequestMapping("/invoice") @SessionAttributes("ListOrderItems") public class InvoiceController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView adminPage() {
System.out.println("Im in /Index** Mapping");
String username;
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
username = auth.getName(); //get logged in username
username.toUpperCase();
// Logic to build menue based on the Role of the user.
HashMap hm = new HashMap();
OrderItems od = new OrderItems();
ModelAndView model = new ModelAndView();
model.addObject("usr", username);
//Set the object for Menue Links on the Page
model.addObject("mnue", hm);
model.setViewName("index");
model.addObject("odi",od);
return model;
} }
Dispatcher Servlet configuration file: <mvc:resources mapping="/webjars/**" location="/webjars/" />
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
【问题讨论】:
标签: javascript css spring-mvc