spring mvc 初级问题。

山城忙碌人 2010-08-11 11:03:47
RT

@Controller
@RequestMapping("/index.htm")
public class Test{
@RequestMapping(params = "method=herfMethod")
public String fromMethod(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String name = request.getParameter("name");
String word = request.getParameter("word");
request.setAttribute("hello", name+","+word);
return "index";
}
}

为什么我自己定义的方法,里面放HttpServletRequest request,HttpServletResponse response这两个对象,直接就能拿来用,在这里我还可以用其它的对象吗?是不是注解了@RequestMappin后就能直接用request,response了。
谢谢!
...全文
26 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
thy_java 2010-08-23
  • 打赏
  • 举报
回复
@是注解 request,response 掉才有

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧