我的javascript中包含JSP变量,例如AJAX调用网址的示例
url: "${pageContext.request.contextPath}/darf/${assignment.ffaWholeId}",
据我所知,实际上是在项目中将javascript文件创建为.jsp
文件,并将darf-js.jsp
放入了WEB-INF/views/js
文件夹中。我不确定如何从父jsp darf.jsp
引用它。我尝试了以下
<script src="${pageContext.request.contextPath}/js/darf-js.jsp"></script>
<script src="${pageContext.request.contextPath}/darf-js.jsp"></script>
<script src="${pageContext.request.contextPath}/views/js/darf-js.jsp</script>
我的视图解析器
<beans:bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass">
<beans:value>org.springframework.web.servlet.view.tiles3.TilesView
</beans:value>
</beans:property>
<beans:property name="order">
<beans:value>1</beans:value>
</beans:property>
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix">
<beans:value>/WEB-INF/views/</beans:value>
</beans:property>
<beans:property name="suffix">
<beans:value>.jsp</beans:value>
</beans:property>
<beans:property name="order">
<beans:value>#{tilesViewResolver.order+1}</beans:value>
</beans:property>
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix">
<beans:value>/WEB-INF/views/js</beans:value>
</beans:property>
<beans:property name="suffix">
<beans:value>.jsp</beans:value>
</beans:property>
<beans:property name="order">
<beans:value>#{tilesViewResolver.order+2}</beans:value>
</beans:property>
</beans:bean>