Java Spring MVC+;Apache2Tiles返回json对象

Java Spring MVC+;Apache2Tiles返回json对象,java,json,apache,spring-mvc,tiles2,Java,Json,Apache,Spring Mvc,Tiles2,我用ApacheTiles配置了SpringMVC <context:component-scan base-package="controllers"/> <!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">--> <!--<property name="prefix" value="/WEB-INF/pages/"/&

我用ApacheTiles配置了SpringMVC

 <context:component-scan base-package="controllers"/>

<!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
    <!--<property name="prefix" value="/WEB-INF/pages/"/>-->
    <!--<property name="suffix" value=".jsp"/>-->
<!--</bean>-->

<bean id="tilesConfigure" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/tailesconfig/general.xml</value>
        </list>
    </property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
</bean>



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

但当我请求时,我得到: 无法在名为“mvc dispatcher”的servlet中解析名为“greeting”的视图
对不起我的英语,谢谢你的帮助

查看spring的ContentNegotiatingViewResolver

尝试使用@ResponseBody注释。谢谢,我通过RestController和com.fasterxml.jackson.core解决了这个问题
public class Greeting {

    private final long id;
    private final String content;

    public Greeting(long id, String content) {
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }
}

private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();

@RequestMapping(value = "/greeting",produces = "application/json")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
    return new Greeting(counter.incrementAndGet(),
            String.format(template, name));
}