ui-router states connection between angularJS and spring mvc not bind with Spring controller -
i trying send request spring controller through angularjs ui-router in gives 404 not found exception...
here code: home.jsp through cal js page want call html
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ page session="false" %> <%@ page import="java.sql.*" %> <%@ page import="org.tempuri.*" %> <html> <head> <title>home</title> <script src="resources/libs/angular.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router /0.2.8 /angular-ui-router.min.js"></script> <script type="resources/libs/angular.ui.router.min.js"></script> <script src="resources/js/mock_app.js"></script> </head> <body ng-app="formsubmit"> <!-- ng-controller="formsubmitcontroller -->" <!-- <div > --> <h3 >{{headertext}}</h3> <h1> <center>exit module</center> </h1> <p>employee name ${emp}</p> <% int rid=(integer)request.getattribute("param1"); system.out.println(rid); connection con=null; callablestatement cs=null; string user="root"; string pwd="redhat"; resultset rs=null; string sql=""; string url="jdbc:mysql://172.25.38.148:3306/hrms"; try{ class.forname("com.mysql.jdbc.driver"); con=drivermanager.getconnection(url, user, pwd); cs=con.preparecall("call usp_rolepage_authenticate(?)"); cs.setint(1, rid); rs=cs.executequery(); while(rs.next()){ if(rs.getstring("page_name").equalsignorecase("resignation")){ out.print("<br><ul><li><a href='./resignation'>resignation</a></li><ul></br>"); } if(rs.getstring("page_name").equalsignorecase("exit")) { out.print("<br><ul><li> <a ui-sref='exit'ui-sref-active='active' href='#exit'>exit interview</a> </li><ul></br> "); } /* if(rs.getstring("page_name").equalsignorecase("angularjsformsubmit")) { out.print("<br><ul><li><a href='./angularjsformsubmit'>exit interview ||</a></li><ul></br>"); } */ if(rs.getstring("page_name").equalsignorecase("angularjsformsubmit")) { out.print("<br><ul><li><a href='angularjsformsubmit'>exit interview ||</a></li><ul></br>"); } } }catch(exception e){ e.printstacktrace(); }finally{ con.close(); } %> !-- <a ui-sref='angularjsformsubmit' ui-sref-active='active' href='#angularjsformsubmit'>angularspringdemo</a> --> <div ui-view></div> <p>${msg}</p> </body> </html>
this js page:=
var app=angular.module('formsubmit',['ui.router']); app.config(function($stateprovider,$urlrouterprovider){ $urlrouterprovider.otherwise('/angularjsformsubmit'); $stateprovider .state('angularjsformsubmit',{ url:'/angularjsformsubmit', templateurl:'angularjsformsubmit.html', controller:'formsubmitcontroller' }); }); app.controller('formsubmitcontroller',["$scope", "$http", function($scope, $http) { $scope.list = []; $scope.headertext = 'angularjs post form spring mvc example: submit below form'; $scope.form.name=''; $scope.formdata = { "name1" : $scope.name1, "name2" : $scope.name2, "name3" : $scope.name3, }; //should set object on init. $scope.submit = function() { var response = $http.post('submitmock',{ mockform: formdata}); //passing mockform response.success(function(data, status, headers, config) { $scope.list.push(data); }); response.error(function(data, status, headers, config) { alert("exception details: " + json.stringify({ data: $scope.formdata //used formdata model here })); }); //empty list data after process $scope.list = []; }; }]);
this html page:angularjsformsubmit.html want page content through angular aand springmvc
<!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>insert title here</title> </head> <body> angularspringdemo </body> </html
this spring controller:
@requestmapping(value = "/angularjsformsubmit", method = requestmethod.get) /*public @responsebody person postservice(@requestbody person person) { return person;*/ public string check() { system.out.println("enter name of employeee..."); return "angularjsformsubmit"; } }
Comments
Post a Comment