Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我不能';在GET调用期间无法实现服务器命中。加载页面时,应该为服务器提供什么url(Java+;Spring MVC+;AngularJS)_Java_Angularjs_Spring Mvc_Angular2 Template - Fatal编程技术网

我不能';在GET调用期间无法实现服务器命中。加载页面时,应该为服务器提供什么url(Java+;Spring MVC+;AngularJS)

我不能';在GET调用期间无法实现服务器命中。加载页面时,应该为服务器提供什么url(Java+;Spring MVC+;AngularJS),java,angularjs,spring-mvc,angular2-template,Java,Angularjs,Spring Mvc,Angular2 Template,我是开发Java应用程序的新手。我已经开始通过NetbeansIDE进行编码。我在前端使用了Java和SpringMVC框架,在后端使用了AngularJS 项目结构为: pom.xml看起来像: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.

我是开发Java应用程序的新手。我已经开始通过NetbeansIDE进行编码。我在前端使用了Java和SpringMVC框架,在后端使用了AngularJS

项目结构为:

pom.xml看起来像:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>example1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.0.1.RELEASE</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>example1</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
</project>
SampleClass.java:

package com.airhacks.ping.boundary;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod

@Controller
@RequestMapping("sampleData")
public class SampleClass {

    /**
     *
     * @return
     */
    @RequestMapping(value="/string" , method = RequestMethod.GET)
    public String getStringValue(){
        return "Hi Hello World! Good Morning";
    }

}
context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/example1"/>

bean.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="all">
</beans>

请给我建议一些实现正确的get呼叫的方法。谢谢
ashfaquee.

上下文路径=“/example1”
。。。在其他代码中,您在哪里考虑到了这一点?对不起。我找不到你,先生。您是否在询问使用此/示例1的原因?在创建项目名为“example1”的项目时,它已经配置好了,先生。我的意思是,我看到的只是,
url+'sampleData/string'
,那么你到底在哪里?这个代码有什么错误?@John我明白了-我在问有没有错误。另外,输入的url是什么,所以我们不会猜测
$location.absUrl()添加一些错误处理。还可以在浏览器开发工具网络中检查实际请求以获取线索
上下文路径=“/example1”
。。。在其他代码中,您在哪里考虑到了这一点?对不起。我找不到你,先生。您是否在询问使用此/示例1的原因?在创建项目名为“example1”的项目时,它已经配置好了,先生。我的意思是,我看到的只是,
url+'sampleData/string'
,那么你到底在哪里?这个代码有什么错误?@John我明白了-我在问有没有错误。另外,输入的url是什么,所以我们不会猜测
$location.absUrl()添加一些错误处理。还可以在浏览器开发工具网络中查看实际请求以获取线索
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/example1"/>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="all">
</beans>