Announcement Announcement Module
Collapse
No announcement yet.
InternalResourceViewResolver and CSS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • InternalResourceViewResolver and CSS

    Hi ,

    l have a index.jsp page , which intend to do a link to a 1.css :
    Code:
    <%@ include file="/WEB-INF/jsp/includeTop.jsp" %>
    
    <html>
    <head>
        <title>How to link the CSS ?</title>
    
        <link rel="stylesheet" href="<c:url value="XXX"/>" type="text/css" />
    </head>
    ....
    but l don't know how to write the XXX above ? l tried a lot of combinations (/css/1.css , ../css/1.css , ...etc), but failed .

    l have the InternalResourceViewResolver configure as below ,
    Code:
    	<bean id="viewResolver"	class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
    		<property name="requestContextAttribute"><value>rc</value></property>
    		<property name="prefix"><value>/WEB-INF/jsp/</value></property>
    		<property name="suffix"><value>.jsp</value></property>
    	</bean>
    and a dir structure ,
    Code:
    webAppRootDir  ___  css -- 1.css
                  |
                  |___  WEF-INF ___ classes
                                ___ lib
                                ___ jsp -- index.jsp
                                        |-- ... other jsps
    l read a lot spring's examples , found no similar example , except the country example from the spring distribution ,
    Code:
    <c:set var="css"><spring:theme code="css"/></c:set>
        	<c:if test="${not empty css}"><link rel="stylesheet" href="<c:url value="${css}"/>" type="text/css" /></c:if>
    l tested with the code above , but no luck , still cannot link to the 1.css.

    How to link to a css if my jsp pages are in webAppRootDir/WEB-INF/jsp/.. folder ?

    yatgor.

  • #2
    Hi Yatgor,

    Try
    Code:
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css1.css" />

    Comment


    • #3
      Hi Jeff,
      thanks for your reply , but it did not work.

      But l found the problem in another thread "Problem with stylesheet in acegilogin.jsp page" , http://forum.springframework.org/showthread.php?t=17577 , the problem happened after l setup the acegi security , it block all the *.css , *.js , ..etc , it is indeed an unexpected behaviour.

      yatgor

      Comment

      Working...
      X