jquery - Javascript code is not working inside the spring jsp -
i biginner in spring , need display in spring using jquery.i have imported necessary jquery plugins.but problem javascript code not working inside jsp.i have tested using alert statement , other thing,but none of them work.i don't know do.below jsp code index.jsp:
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4 /loose.dtd"> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title id="description">in demo jqxtree built json data.</title> <spring:url value="/resources/jqx.css" var="jqueryurl" /> <link rel="stylesheet" href="${jqueryurl}" type="text/css"> <spring:url value="/resources/jquery-1.js" var="jqueryaurl" /> <script type="text/javascript" src="${jqueryaurl}"></script> <spring:url value="/resources/demos.js" var="jqueryburl" /> <script type="text/javascript" src="${jqueryburl}"></script> <spring:url value="/resources/jqx_002.css" var="jquerycurl" /> <link rel="stylesheet" href="${jquerycurl}" media="screen"> <spring:url value="/resources/jqxcore.js" var="jquerydurl" /> <script type="text/javascript" src="${jquerydurl}"></script> <spring:url value="/resources/jqxdata.js" var="jqueryeurl" /> <script type="text/javascript" src="${jqueryeurl}"></script> <spring:url value="/resources/jqxbuttons.js" var="jqueryfurl" /> <script type="text/javascript" src="${jqueryfurl}"></script> <spring:url value="/resources/jqxscrollbar.js" var="jquerygurl" /> <script type="text/javascript" src="${jquerygurl}"></script> <spring:url value="/resources/jqxpanel.js" var="jqueryhurl" /> <script type="text/javascript" src="${jqueryhurl}"></script> <spring:url value="/resources/jqxtree.js" var="jqueryiurl" /> <script type="text/javascript" src="${jqueryiurl}"></script> <spring:url value="/resources/jqxdropdownlist.js" var="jqueryjurl" /> <script type="text/javascript" src="${jqueryjurl}"></script> <spring:url value="/resources/jqxlistbox.js" var="jquerykurl" /> <script type="text/javascript" src="${jquerykurl}"></script> <style> .dark_overlay{display:none;position:absolute;top:0%;left:0%;width:100%;height:100%; background-color:black;padding-bottom:500px;z-index:1001; -moz-opacity:0.8;opacity:.80;filter:alpha(opacity=80);}.bright_content{display:none; position:absolute;top:25%;left:25%;width:50%;height:50%;padding:16px; border:16px solid #00ccff;background-color:white;z-index:1002;overflow:auto;}</style> </head> <body> <div id="header" style="height:20%"></div> <div id="content" style="float:left"> <script type="text/javascript"> $(document).ready(function () { document.getelementbyid('bttn').style.display='block'; alert("hai"); }); </script> <div id="jqxwidget"> </div> <div id="bttn" style="display:none;"><input type="button" name="add" id="add" value="add" /><input type="button" name="edit" id="edit" value="edit" /> <input type="button" id="delete" name="delete" value="delete" /> </div> <div style="display: none;" id="lightbox-shadow"></div> <div style="top: 4096px; display: none;line-height: 1.5;" id="lightbox"></div> <div style="display: none;" id="light" class="bright_content"><a href="javascript:void(0)" onclick="document.getelementbyid('light').style.display='none';document.getelementbyid('fade').style.display='none'">close</a><div id="txtbx"><input type="text" id="itemnamess"></div> <div id="jqxdrp" style="display: none;"></div> <div id="ligtbx"></div></div> <div style="display: none;" id="fade" class="dark_overlay"></div> </div> <div id="footer" style="height:20%"></div> </body> </html>
and servlet-context.xml file is:
<?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:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <!-- enable @controller annotation support --> <mvc:annotation-driven /> <!-- map simple view name such "test" /web-inf/views/test.jsp --> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/" /> <property name="suffix" value=".jsp" /> </bean> <!-- scan classpath annotations (eg: @service, @repository etc) --> <context:component-scan base-package="com.gerrytan.pizzashop"/> <!-- jdbc data source. assumed have mysql running on localhost port 3306 username root , blank password. change below if it's not case --> <bean id="mydatasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <property name="driverclassname" value="com.mysql.jdbc.driver"/> <property name="url" value="jdbc:mysql://localhost:3306/test"/> <property name="username" value="root"/> <property name="password" value="kca@fnpl#12"/> <property name="validationquery" value="select 1"/> </bean> <!-- hibernate session factory --> <bean id="mysessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="mydatasource"/> <property name="packagestoscan"> <array> <value>com.gerrytan.pizzashop</value> </array> </property> <property name="hibernateproperties"> <value> hibernate.dialect=org.hibernate.dialect.mysqldialect </value> </property> </bean> <!-- hibernate transaction manager --> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="mysessionfactory"/> </bean> <!-- activates annotation based transaction management --> <tx:annotation-driven transaction-manager="transactionmanager"/> <mvc:resources mapping="/resources/**" location="/resources/" /> </beans>
i think may simple mapping issue.but don't know problem is.please me.
try
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <html> <head> <link href="<c:url value="/resources/main.css" />" rel="stylesheet"> <script src="<c:url value="/resources/jquery.1.10.2.min.js" />"></script> <script src="<c:url value="/resources/main.js" />"></script> </head> <body> <h1>1. test css</h1> <h2>2. test js</h2> <div id="msg"></div> </body> </html>
and js , css file should in resources folder.
Comments
Post a Comment