jquery - Not able to render the request to another html from controller using angularjs + spring MVC 3.0 -


logon.jsp

    <!doctype html>     <html ng-app="angularspring">     <head>      </head>      <body ng-controller="logoncontroller">      <form>             <div>                 textbox : <input type="text"  ng-model="person.username" />             </div>             <div>                 password : <input type="password" ng-model="person.password" />             </div>             <div ng-view></div>             <button type="submit" ng-click="login(person)"> submit               </button>     </form>      <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>     <script type="text/javascript" src="js/jquery.i18n.properties-min-1.0.9.js"></script>     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>     <script type="text/javascript" src="js/init.js"></script>     <script type="text/javascript" src="js/controller.js"></script>     <script type="text/javascript" src="js/i18n.js"></script>     <script type="text/javascript" src="js/base64.js"></script>     <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>       </body>       </html> 

controller.js

        var = angular.module('angularspring',[]);           as.controller('logoncontroller', function ($scope, $http) {             var actionurl = 'action/checkusernameandpassword/';                $scope.login = function (person) {                   $http.post(actionurl,$scope.person);              };           });       

web.xml

    <context-param>             <param-name>contextconfiglocation</param-name>             <param-value>                 /web-inf/action-servlet.xml             </param-value>         </context-param>          <listener>             <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>         </listener>          <!-- spring mvc -->         <servlet>             <servlet-name>action</servlet-name>             <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>             <load-on-startup>1</load-on-startup>         </servlet>         <servlet-mapping>             <servlet-name>action</servlet-name>             <url-pattern>/action/*</url-pattern>         </servlet-mapping>           <welcome-file-list>         <welcome-file>logon.html</welcome-file>       </welcome-file-list>   

in action-servlet.xml file contains below tags , classes

action-servlet.xml

    <mvc:annotation-driven/>          <context:annotation-config />      <context:component-scan base-package="com.pack" />      <bean class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"></bean>       <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver" >       <property name="prefix" value="" />       <property name="suffix" value=".html" />      </bean> 

logoncontroller.java

in logoncontroller able request values bind person object not able render request logonsuccess.html

    @requestmapping(value = "/checkusernameandpassword", method = requestmethod.post)     @responsebody      public modelandview logon(@requestbody person person) {              return new modelandview("web-inf/views/logonsuccess");         } 

as per understanding able bind modelattribute not able dispatch required view.

here's observe

you have @responsebody annotation on logon method returns modelandview object.

if want return html view remove @responsebody annotation.

you can read more here

also in action-servlet.xml specify prefix property of viewresolver location of html files think web-inf/views

<bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix">         <value>/web-inf/views/</value>     </property>     <property name="suffix">         <value>.html</value>     </property> </bean> 

now can return modelandview like

 return new modelandview("logonsuccess"); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -