我遇到了问题。这是我第一次这样做。我在JSP中使用Spring Rest Controller和Display生成了一个随机数程序。
现在我尝试的是我映射HTML文件,显示我在JSP中获得的内容。但我面对这个错误
找不到带URI的HTTP请求的映射
我尝试了各种网站,但没有理解那里的错误
这里我有HTML的高清图,我每隔5秒刷新一次页面。所以,我从服务器获取y轴的值,时间绘制在x轴上。我也被困在HTML文件的Ajax调用中。我无法弄清楚如何从服务器和其他轴值中获取一个轴值。
我在这里粘贴代码---
我的控制器 -
package com.xyz.rest.temperature.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.lucid.rest.temperature.exception.InvalidRangeException;
import com.lucid.rest.temperature.exception.NegativeNumberException;
import com.lucid.rest.temperature.util.RandomNumberGenerator;
@RestController
public class ReadingController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getReading() throws NegativeNumberException,
InvalidRangeException {
return new Integer(new RandomNumberGenerator().generateRandomNumber(
100, 50)).toString();
}
@RequestMapping(value = "/staticPage", method = RequestMethod.GET)
public String redirect() {
return "redirect:/jsp/hello.htm";
}
}
我的调度员Servlet -
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.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">
<mvc:view-controller path="/" view-name="/WEB-INF/jsp/hello.html"/>
<context:component-scan base-package="com.xyz.rest.temperature.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
我的web.xml文件是 -
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Temperature Reading</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>hello.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>TemperatureReading</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/TemperatureReading-servlet*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>TemperatureReading</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/index.jsp</location>
</error-page>
</web-app>
我的JSP是 -
<%@page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Random generator</title>
<%@ page language='java'%>
<%@ page import='java.*'%>
<%@ page
import="com.xyz.rest.temperature.controller.ReadingController"%>
<%
ReadingController obj = new ReadingController();
%>
</head>
<body>
<%
String i = obj.getReading();
%>
<%=i%>
</body>
</html>
我的HTML文件是 -
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<style type="text/css">
</style>
<title>Temprature</title>
<script type='text/javascript'>//<![CDATA[
$(document).ready(function() {
var options = {
chart: {
renderTo: 'cpuhealth',
type: 'column'
},
title: {
text: 'CPU Usage'
},
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function(){
var chart = new Highcharts.Chart(options);
$.getJSON('http://url-to-json-file/index.php', function(jsondata) {
options.series[0].data = JSON.parse(jsondata.cpu);
});
}, 5000);
}
},
yAxis: {
labels: {
formatter: function() {
return this.value + ' %';
}
},
title: {
text: 'Usage (%)'
}
},
xAxis: {
title: {
text: 'CPU Core ID#'
}
},
tooltip: {
formatter: function() {
return 'CPU Core: <b>' + this.x + '</b><br>Usage <b>' + this.y + '%</b>';
}
},
legend: {
enabled: false
},
series: [{}]
};
}
//]]>
</script>
</head>
<body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</body>
</html>
所以我几乎粘贴了所有东西。请帮我弄清楚错误是什么,以及如何克服HTMl中的轴值问题
感谢任何帮助。如果您不明白,请发表评论。感谢