xhr.send((s.hasContent&& s.data)|| null);在jquery

时间:2016-12-24 19:46:14

标签: javascript jquery spring-mvc

事情突然停止为我工作。我只是将我的页面从一个位置移动到另一个位置但是之后,当我看到行号xhr.send( ( s.hasContent && s.data ) || null );时,我的来电给我发了404错误现在​​我不明白我做了什么错误只是复制和粘贴。

这是我的config.java

package org.pkb.springlCalendar.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration
@ComponentScan("org.pkb.springCalendar.controller")
@EnableTransactionManagement
// Load to Environment.
@PropertySource("classpath:datasource-cfg.properties")
public class ApplicationContextConfig {

  // The Environment class serves as the property holder
  // and stores all the properties loaded by the @PropertySource
  @Autowired
  private Environment env;



  @Bean
  public ResourceBundleMessageSource messageSource() {
      ResourceBundleMessageSource rb = new ResourceBundleMessageSource();
      // Load property in message/validator.properties
      rb.setBasenames(new String[] { "messages/validator" });
      return rb;
  }

  @Bean(name = "viewResolver")
  public InternalResourceViewResolver getViewResolver() {
      InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
      viewResolver.setPrefix("/WEB-INF/pages/");
      viewResolver.setSuffix(".jsp");
      viewResolver.setExposeContextBeansAsAttributes(true);
      return viewResolver;
  }

  @Bean(name = "dataSource")
  public DataSource getDataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();

      // See: dataSource-cfg.properties
      dataSource.setDriverClassName(env.getProperty("ds.database-driver"));
      dataSource.setUrl(env.getProperty("ds.url"));
      dataSource.setUsername(env.getProperty("ds.username"));
      dataSource.setPassword(env.getProperty("ds.password"));

      System.out.println("## getDataSource: " + dataSource);

      return dataSource;
  }

  // Transaction Manager
  @Autowired
  @Bean(name = "transactionManager")
  public DataSourceTransactionManager getTransactionManager(DataSource dataSource) {
      DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);

      return transactionManager;
  }

}

下面是我的jsp

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<!-- <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

<link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel = "stylesheet"> -->


<script lang="text/javascript">
var holi="";
function day_title(day_name) {
document.write("<TD ALIGN=center WIDTH=35>"+day_name+"</TD>")
}
function hilite_today(day,mm) {
if ((this_day == day) && (this_month == mm))
document.write("<FONT COLOR=\"#FF0000\">")
}
function hilie_holiday(day,mm){
    console.log("inside holiday method");
    for(var i=0;i<holi.length;i++){
        var parts=holi[i].date.split('-');
        if(parts[1]==mm && parts[2]==day){

            document.write("<FONT COLOR=\"#00FF00\">")
        }

    }

}
function makeArray(n) {
this.length=n;
for (var i = 1; i <= n; i++)
this[i] = 0
return this
}
function fill_table(m_name,m_length,mm) {
day=1
document.write("<center><TABLE BORDER=3 CELLSPACING=3 CELLPADDING=%3><TR>")
document.write("<TD COLSPAN=7 ALIGN=center><B>"+m_name+   this_year+"</B><TR>")
day_title("Sun")
day_title("Mon")
day_title("Tue")
day_title("Wed")
day_title("Thu")
day_title("Fri")
day_title("Sat")
document.write("</TR><TR>")
for (var i=1;i<start_day;i++) {
document.write("<TD>")
}
for (var i=start_day;i<8;i++) {
    if(day.toString().length==1 && mm.toString().length==2) 
        document.write("<TD ALIGN=center><a href='#'class='clickMe' id="+"0"+day+mm+">")
    else if(day.toString().length==2 && mm.toString().length==1)
        document.write("<TD ALIGN=center><a href='#'class='clickMe' id="+day+"0"+mm+">")
    else if(day.toString().length==1 && mm.toString().length==1)
        document.write("<TD ALIGN=center><a href='#' class='clickMe' id="+"0"+day+"0"+mm+">")
    else
        document.write("<TD ALIGN=center><a href='#'class='clickMe' id="+day+mm+">")
        hilite_today(day,mm)

document.write(day+"</TD><FONT COLOR='#000000'>")
day++;
}
document.write("<TR>")
while (day <= m_length) {
for (var i=1;i<=7 && day<=m_length;i++) {
    if(day.toString().length==1 && mm.toString().length==2) 
        document.write("<TD ALIGN=center><a href='#' class='clickMe' id="+"0"+day+mm+">")
    else if(day.toString().length==2 && mm.toString().length==1)
        document.write("<TD ALIGN=center><a href='#' class='clickMe' id="+day+"0"+mm+">")
    else if(day.toString().length==1 && mm.toString().length==1)
        document.write("<TD ALIGN=center><a href='#' class='clickMe' id="+"0"+day+"0"+mm+">"
        )
    else
        document.write("<TD ALIGN=center><a href='#' class='clickMe' id="+day+mm+">")
hilite_today(day,mm)

document.write(day+"</TD><FONT COLOR='#000000'>")
day++
}
document.write("</TR><TR>")
}   
document.write("</TR></TABLE></center><BR>")
start_day = i
}

</script>
</head>
<body>
<script lang="JavaScript">
month=new makeArray(12)
month[1]="January"
month[2]="February"
month[3]="March"
month[4]="April"
month[5]="May"
month[6]="June"
month[7]="July"
month[8]="August"
month[9]="September"
month[10]="October"
month[11]="November"
month[12]="December"
month_length = new makeArray(12)
month_length[1]=31
month_length[2]=29
month_length[3]=31
month_length[4]=30
month_length[5]=31
month_length[6]=30
month_length[7]=31
month_length[8]=31
month_length[9]=30
month_length[10]=31
month_length[11]=30
month_length[12]=31
today = new Date()
this_day = today.getDate()
this_month = today.getMonth()+1
this_year = today.getFullYear()
console.log(" this yeR",today);
begin_date = new Date("January 1,"+ this_year)
start_day = begin_date.getDay()+1
if (start_day == 1){
start_day = 8
}
for (var m = 1;m<=12;m++){
fill_table(month[m],month_length[m],m)
}
$(document).ready(function() {
    holidays();

});





function holidays(){
    var home='<%=request.getContextPath()%>';

    console.log(home);


     $.get("/secondAssign/holidays", function(data, status){
           alert("Data: " + data + "\nStatus: " + status);
            holi=data;
            console.log("holi:",holi);
            hilite_holidays();
        });

}
function hilite_holidays(){
    $.each(JSON.parse(holi), function(i, item) {
    var holidayDate=item.date+"";
   var parts= holidayDate.split("-");
   alert("parts:"+parts[2]);
   var dayId = parts[2] + parts[1],
   day = $("#" + dayId);

   day.css("color", "green")
       .html($("<label/>", {
         title: item.description,
         html: day.html()
       }))
       .find("label").tooltip();


});
}

</script>

</body>
</html>

下面是我的控制器

package org.pkb.springCalendar.controller;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.pkb.springCalendar.model.HolidayManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LoadController {
    @Autowired
    HolidayManager holidayManager;


    @RequestMapping(value={"/holidays"},method=RequestMethod.GET)
    public @ResponseBody String loadHolidays(){
        System.out.println("in load controller");
        ObjectMapper mapper=new ObjectMapper();
        String jsonString="";
        try {
                jsonString=mapper.writeValueAsString(holidayManager.loadHolidays());
        } catch (JsonGenerationException e) {

            e.printStackTrace();
        } catch (JsonMappingException e) {

            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return jsonString;
    }
}

0 个答案:

没有答案