java - How to display file in Spring-Controller -


i having issue. first time doing this. have generated random number program using spring rest controller , display in jsp.

now tried mapped html file showing getting in jsp. face error

no mapping found http request uri

and have tried various sites not understanding wrong in that

here have highchart in html , refreshing page after every 5 seconds. so, taking value server y-axis , time plotted on x-axis. stuck in ajax call html file. not able figure out how take 1 axis value server , other axis value time.

i pasting code here---

my controller-

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";        } } 

my dispatcher 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> 

my web.xml file is-

<?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> 

my jsp is-

<%@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 = obj.getreading();     %>     <%=i%> </body> </html> 

and html file is--

<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 updating of 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> 

so have pasted everything. please me figure out error , how can overcome axis value issue in html

any appreciated. please comment if don't understand anything. thanks


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -