无法使用spring mvc映射角度UI

时间:2016-05-17 16:05:29

标签: angularjs spring spring-mvc spring-rest

分派器:

@ECHO OFF
FOR %%F IN ("\full\path\to\your\files\*.txt") DO (
    FOR /F "usebackq tokens=1,2,3 delims=    " %%A IN ("%%~fF") DO CALL :Process "%%A" "%%B" "%%C"
)
GOTO :eof

:Process
ECHO [1] = "%~1"
ECHO [2] = "%~2"
ECHO [3] = "%~3"
GOTO :eof

控制器类:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="com.nt.beans" />

    <mvc:resources mapping="/resources/**" location="/" />
    <mvc:annotation-driven />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">

        <property name="prefix">
            <value>/WEB-INF/views/</value>
        </property>

        <property name="suffix">
            <value></value>
        </property>

    </bean>
</beans>

UI-路由器:

@Controller
public class IndexController {//Serves main index.html

    @RequestMapping("/**")
    public String getIndexPage() {
        return "/";
    }
}

索引jsp页面:

myApp.config(function ($stateProvider, $locationProvider, $urlRouterProvider) {

    // For any unmatched url, redirect to /login
    $urlRouterProvider.otherwise("/Login");

    // Now set up the states
    $stateProvider
            .state('Login', {
                url: "/Login",
                views: {
                    header: header,
                    content: {
                        templateUrl: 'views/Login.html',
                        controller: function () {
                        }
                    },
                    footer: footer
                }
            });

    $locationProvider.html5Mode({
        enabled: false,
        requireBase: true
    });
});

当我运行应用程序时,它应该加载login.html但它在控制台中显示错误,如:

<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html lang="en" ng-app="myApp"> <head> <title>BulkSMS - HTML</title> <base href="/BulkSMS2/"> <!-- Bootstrap core CSS --> <link href="resources/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"/> <!--font-awesome--> <link href="resources/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/> <!--Bootstrap social--> <link href="resources/bower_components/bootstrap-social/bootstrap-social.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="wrap"> <!--main content--> <div ui-view="content"></div> </div> <!--Bootstrap core JavaScript--> <script src="resources/bower_components/bootstrap/dist/js/bootstrap.min.js" type="text/javascript"></script> <!--angular related scripts--> <script src="resources/bower_components/angular/angular.min.js" type="text/javascript"></script> <script src="resources/bower_components/angular-ui/build/angular-ui.min.js" type="text/javascript"></script> <script src="resources/bower_components/angular-ui-router/release/angular-ui-router.min.js" type="text/javascript"></script> <script src="resources/js/angular_module.js" type="text/javascript"></script> <script src="resources/js/controllers/StateProvider.js" type="text/javascript"></script> <script src="resources/js/controllers/LoginController.js" type="text/javascript"></script> </body> </html>

dispatcher.xml中的前缀为Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8084/BulkSMS2/resources/bower_components/bootstrap-social/bootstrap-social.css",因此其中的login.html页面应该加载,并且在控制器中我将路径返回为WEB-INF/views,因此任何不匹配的url模式都应该加载登录页面据国家提供者说。

0 个答案:

没有答案