How to import css/js in spring MVC application jsp page -
i new spring mvc , creating user registration page , there need put external css , import external js .
i put script tag src , link tag href. think in spring mvc application not work straight forward. added resourceservlet mapping still not working
i not able find way how csn include these assets in jsp file.
please me one.
regards, pranav
i added following mapping
but after getting exception trace below
severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception: line 34 in xml document servletcontext resource [/web-inf/mvc-dispatcher-servlet.xml] invalid; nested exception org.xml.sax.saxparseexception: cvc-complex-type.2.4.c: matching wildcard strict, no declaration can found element 'mvc:resources'. @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.doloadbeandefinitions(xmlbeandefinitionreader.java:396) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:334) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:302) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:143) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:178) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:149) @ org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:124) @ org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:93) @ org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:130) @ org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:458) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:388) @ org.springframework.web.context.contextloader.createwebapplicationcontext(contextloader.java:261) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:192) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:47) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:3972) @ org.apache.catalina.core.standardcontext.start(standardcontext.java:4467) @ org.apache.catalina.core.containerbase.start(containerbase.java:1045) @ org.apache.catalina.core.standardhost.start(standardhost.java:785) @ org.apache.catalina.core.containerbase.start(containerbase.java:1045) @ org.apache.catalina.core.standardengine.start(standardengine.java:443) @ org.apache.catalina.core.standardservice.start(standardservice.java:519) @ org.apache.catalina.core.standardserver.start(standardserver.java:710) @ org.apache.catalina.startup.catalina.start(catalina.java:581) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.apache.catalina.startup.bootstrap.start(bootstrap.java:289) @ org.apache.catalina.startup.bootstrap.main(bootstrap.java:414) caused by: org.xml.sax.saxparseexception: cvc-complex-type.2.4.c: matching wildcard strict, no declaration can found element 'mvc:resources'. @ com.sun.org.apache.xerces.internal.util.errorhandlerwrapper.createsaxparseexception(unknown source) @ com.sun.org.apache.xerces.internal.util.errorhandlerwrapper.error(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmlerrorreporter.reporterror(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmlerrorreporter.reporterror(unknown source) @ com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator$xsierrorreporter.reporterror(unknown source) @ com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator.reportschemaerror(unknown source) @ com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator.handlestartelement(unknown source) @ com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator.emptyelement(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmlnsdocumentscannerimpl.scanstartelement(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl.next(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmlnsdocumentscannerimpl.next(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl.scandocument(unknown source) @ com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(unknown source) @ com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(unknown source) @ com.sun.org.apache.xerces.internal.parsers.xmlparser.parse(unknown source) @ com.sun.org.apache.xerces.internal.parsers.domparser.parse(unknown source) @ com.sun.org.apache.xerces.internal.jaxp.documentbuilderimpl.parse(unknown source) @ org.springframework.beans.factory.xml.defaultdocumentloader.loaddocument(defaultdocumentloader.java:75) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.doloadbeandefinitions(xmlbeandefinitionreader.java:388) ... 28 more
please give suggestion on this.
regards, pranav
put css, js, image files, etc., directory (which may contain subdirectories) in web site, , map requests directory:
<mvc:resources mapping="/resources/**" location="/public-resources/"/>
in example files in public-resources
directory, , refer them using /resources
in link in jsp.
for more information see [spring docs]http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-config-static-resources
Comments
Post a Comment