2012-02-24 3 views
5

모두, 내가 JSP 페이지에 스크립트 태그를 포함하여 이상한 문제에 직면하고있다스크립트 태그

. 세 개의 스크립트 중 첫 번째 스크립트 만 포함하면 최종 페이지에서 끝납니다. 여기

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE tiles-definitions PUBLIC 
    "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN" 
    "http://tiles.apache.org/dtds/tiles-config_2_1.dtd"> 
    <tiles-definitions> 
    <definition extends="registration" name="register/default"> 
    <put-attribute name="body" value="/WEB-INF/views/register/register.jspx"/> 
    </definition>  
    </tiles-definitions> 

이 (registration.jspx)

<html xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:tiles="http://tiles.apache.org/tags-tiles" xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0"> 
<jsp:output doctype-root-element="HTML" doctype-system="about:legacy-compat" /> 
<jsp:directive.page contentType="text/html;charset=UTF-8" /> 
<jsp:directive.page pageEncoding="UTF-8" /> 
<jsp:output omit-xml-declaration="true" /> 
<head> 
<c:url var="rootUrl" value="/resources/" /> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="X-UA-Compatible" content="IE=8" /> 
<link rel="stylesheet" type="text/css" href="/resources/css/screen.css" /> 
<link rel="stylesheet" type="text/css" href="/resources/css/openid.css" /> 
<link rel="stylesheet" type="text/css" href="/resources/css/openid-shadow.css" /> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"/> 
<script type="text/javascript" src="/resources/js/openid-jquery.js"/> 
<script type="text/javascript" src="/resources/js/openid-en.js"/> 
<script type="text/javascript"> 
//<![CDATA[ 
    $(document).ready(function() { 
     openid.init('openid_identifier'); 
    }); 
//]]> 
</script> 
<title>Mystery Shopping</title> 
</head> 
<body> 
    <tiles:insertAttribute name="header" /> 
    <tiles:insertAttribute name="body" /> 
</body> 
</html> 

은 신체 부위 속성은 페이지 코드입니다 : 여기 다음과 같이 내가보기 정의는 레이아웃

<?xml version="1.0" encoding="UTF-8"?> 
<!--$Id$ --> 
<!DOCTYPE tiles-definitions PUBLIC 
     "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN" 
     "http://tiles.apache.org/dtds/tiles-config_2_1.dtd"> 
<tiles-definitions> 
<definition name="default" template="/WEB-INF/layouts/default.jspx"> 
    <put-attribute name="header" value="/WEB-INF/views/header.jspx" /> 
    <put-attribute name="submenu" value="/WEB-INF/views/submenu.jspx" /> 
    <put-attribute name="body" value="/WEB-INF/views/body.jspx" /> 
    <put-attribute name="footer" value="/WEB-INF/views/footer.jspx" /> 
</definition> 
<definition name="registration" template="/WEB-INF/layouts/registration.jspx"> 
    <put-attribute name="header" value="/WEB-INF/views/header.jspx" /> 
    <put-attribute name="body" value="/WEB-INF/views/body.jspx" /> 
</definition> 
</tiles-definitions> 

을 정의하는 방법이다 그런 다음 openid-selector가있는 양식을 포함하는 register.jspx라는 jspx 페이지에서 재정의됩니다. 내가

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=8"> 
<link rel="stylesheet" type="text/css" href="/resources/css/screen.css"> 
<link rel="stylesheet" type="text/css" href="/resources/css/openid.css"> 
<link rel="stylesheet" type="text/css" href="/resources/css/openid-shadow.css"> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"> 
<title>Mystery Shopping</title> 
</head> 

내가 페이지 소스보기 ((불을 지르고 통해 요소를 검사 할 때) 나는 다음과 같은 코드를 볼이 등록 페이지의 URL에 액세스 할 때 자원 폴더는

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> 

<!-- Scans within the base package of the application for @Components to configure as beans --> 
<context:component-scan base-package="vm.brands.controller" /> 

<mvc:resources mapping="/resources/**" location="/resources/" /> 

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> 

</beans> 

를 매핑 된 unformatted) 그렇지 않으면 보이지 않는 스크립트 태그를 보았습니다. 그러나 소스보기의 다른 태그처럼 서식이 지정된 것처럼 보이지는 않습니다.

<html version="2.0"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><meta content="IE=8" http-equiv="X-UA-Compatible"/><link href="/resources/css/screen.css" type="text/css" rel="stylesheet"/><link href="/resources/css/openid.css" type="text/css" rel="stylesheet"/><link href="/resources/css/openid-shadow.css" type="text/css" rel="stylesheet"/><script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"/><script src="/resources/js/openid-jquery.js" type="text/javascript"/><script src="/resources/js/openid-en.js" type="text/javascript"/><script type="text/javascript"> 
    $(document).ready(function() { 
     openid.init('openid_identifier'); 
    }); 

그리고 나는이 이상한 행동 때문에 전혀 아이디어가 없습니다.

해결 :는하지만, 새로운 질문이 도움 랄프에 대한

덕분에 팝업 ; 나는

<spring:url value="/resources/js/openid-jquery.js" var="openid-jquery_url"/> 
<spring:url value="/resources/js/openid-en.js" var="openid-en_url"/> 
<script src="${openid-jquery_url}" type="text/javascript"><jsp:text> </jsp:text></script> 
<script src="${openid-en_url}" type="text/javascript"><jsp:text> </jsp:text></script> 

는 HTML 렌더링 귀하의 제안 시도 (다시 어떤 아이디어 왜, 내가 좀 너무 ;-)를 검색하는 계층입니다)

<script src="0" type="text/javascript"> 
<script src="0" type="text/javascript"> 

을하지만

<c:url var="rootUrl" value="/resources/" /> 
<script src="${rootUrl}js/openid-jquery.js" type="text/javascript"><jsp:text> </jsp:text></script> 
<script src="${rootUrl}js/openid-en.js" type="text/javascript"><jsp:text> </jsp:text></script> 
작동이 양식을 가지고

이 예상되는 출력을 제공

<script src="/resources/js/openid-jquery.js" type="text/javascript"> 
<script src="/resources/js/openid-en.js" type="text/javascript"> 

그것은 봄에 문제가 : URL 태그 나 스크립트 태그에 내용이없는 경우 일부 브라우저 문제가 있기 때문에, 뭔가

이 형식
+0

나는 이것이 원인이라고 생각하지 않는다. 그러나 당신은'jquery-1.7.1.min.js' 폼을 서버 리소스 대신에 다른 URL 인'http : // code.jquery.com/jquery-1.7.1.min.js' URL을로드하는 것으로 보았습니까? – Ralph

+0

yeap jquery 서버의 호스팅 된 모드에서 가져 오는 방법이있을 때 웹 응용 프로그램에 사본을 저장하는 것이 유용하지 않다고 생각했습니다. 나는 spring을 사용하지 않았다 : jquery를위한 url 포맷은 처음부터 잘 포함되어 있었기 때문이다. –

답변

12

를 사용하여 자바 스크립트 태그를 놓친 거지 :

<spring:url value="/resources/js/openid-jquery.js" var="openid-jquery_url" /> 
<script src="${openid-jquery_url}" type="text/javascript"><!-- required for FF3 and Opera --></script> 

또는

<script src="${openid-jquery_url}" type="text/javascript"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script> 

이렇게하면 jspx 파서가 태그를 최소화하지 못하기 때문입니다.

+0

나는 내 질문에 대답 할 수 없어서 질문을 편집했다. 그것을 작동하지만 c : url을 통해 얻었습니다. spring : url이 0으로 vars를 대체했습니다. –

1

자바 태그의 한 가지 문제점은 닫기 태그가 있어야한다는 것입니다. 마지막에 />를 사용하여 바로 가기를 사용할 수 없습니다.

잘못된 : <script type="text/javascript" src="script.js"/>

올바른 : <script type="text/javascript" src="script.js"></script>

0

이전 실제로 필요한 의견 (type="text/javascript"jsp:text 태그)하지만, 원래의 질문에 당이 특정의 spring:url과는 아무 상관이 없습니다. (-) 당신은 대시를 사용하는

var에 이름을 :

var="openid-jquery_url" 

밑줄로 교체하고 모든 마법처럼 작동합니다 ... BTW

var="openid_jquery_url" 

, 동일한 마찬가지입니다 c:url이지만, 전환 할 때 대시가없는 다른 자동차 이름을 사용했을뿐입니다.

관련 문제