81,092
社区成员
发帖
与我相关
我的任务
分享
@Controller
@RequestMapping("hello")
public class App
{
@RequestMapping(value="/getkey",
method=RequestMethod.GET,
//headers="Accept=text/plain",
produces="text/plain;charset=utf-8"
)
public @ResponseBody String getKey(@RequestParam String key){
return getValue(key);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 对包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能 稍后会创建该包:webmvct.cmd -->
<context:component-scan base-package="com.TYYJ"/>
<!-- 定义Spring MVC 的模板文件 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <!-- 支持JSTL -->
<property name="prefix" value="/WEB-INF/jsp/" /> <!-- 模板的路径 -->
<property name="suffix" value=".jsp" /> <!-- 模板文件的后缀-->
</bean>
</beans>