论坛首页 Java企业应用论坛

一个简单的web框架-beetlefly

浏览 9451 次
精华帖 (0) :: 良好帖 (5) :: 新手帖 (7) :: 隐藏帖 (3)
作者 正文
   发表时间:2009-05-29  
jindw 写道
没看到什么亮点。

#         public View create(HttpServletRequest req, HttpServletResponse resp){ 
#                 String title=req.getParameter("title"); 
#                 String content=req.getParameter("content"); 

不能吧getParameter去掉吗?繁琐。

给个建议,http参数可以自动注入吗?
比如:
public String cteate(String title,String content,int pageSize,int[] otherParams){
}

编译的时候,参数名称可能被去掉,不过好像可以通过系统标注提醒编译器保留参数名称的。


这个想法好,一直用spring mvc ,思想僵化了。
其实,实现起来也很简单,以后改进。
0 请登录后投票
   发表时间:2009-05-30  
能写山寨框架的都是牛人!
0 请登录后投票
   发表时间:2009-05-31  
jindw 写道
没看到什么亮点。

#         public View create(HttpServletRequest req, HttpServletResponse resp){ 
#                 String title=req.getParameter("title"); 
#                 String content=req.getParameter("content"); 

不能吧getParameter去掉吗?繁琐。

给个建议,http参数可以自动注入吗?
比如:
public String cteate(String title,String content,int pageSize,int[] otherParams){
}

编译的时候,参数名称可能被去掉,不过好像可以通过系统标注提醒编译器保留参数名称的。

 

我的山寨框架就有基本的参数绑定功能

http://stworthy.iteye.com/admin/blogs/367304

0 请登录后投票
   发表时间:2009-05-31  
to stworthy.
谢谢,提供。我已经下载了。有时间,参考你的实现一下。
0 请登录后投票
   发表时间:2009-05-31  
哎,看看php/ruby是咋实现这些东西的

java本来就简单不到哪去,因为servlet api本身就没那么动态。

如果要简单多规定,少编程就是了,不要再要什么url mapping、注解注入业务类了。
0 请登录后投票
   发表时间:2009-06-01  
jander 写道
jindw 写道
没看到什么亮点。

#         public View create(HttpServletRequest req, HttpServletResponse resp){ 
#                 String title=req.getParameter("title"); 
#                 String content=req.getParameter("content"); 

不能吧getParameter去掉吗?繁琐。

给个建议,http参数可以自动注入吗?
比如:
public String cteate(String title,String content,int pageSize,int[] otherParams){
}

编译的时候,参数名称可能被去掉,不过好像可以通过系统标注提醒编译器保留参数名称的。


这个想法好,一直用spring mvc ,思想僵化了。
其实,实现起来也很简单,以后改进。


哈哈现在Spring MVC就是这么干的,其实Spring mvc可以更大胆.

下面是Domain(也可以同时是Model)
@Entity
public Person{
   @Id
   pirvate int id
   private String name;
   private String password;

   get();set();这个就先省了。
}


下面Controller
@Controller
public PersonController{
   
    
    public String addPerson(String password,String name,ModelMap model){
          处理从得到的Parameter(password,name),只要和页面的name一致就行。
           model.add..(password);(此向前台返回数据)
           return "/index.jsp"
    }

    上面不算露骨的,下面更方便
     public addPerson(Person person,ModelMap model){
        如果前台password为空person也不会报错,只会给person的password一个默认值!
    }

}






0 请登录后投票
   发表时间:2009-06-02  
stworthy 写道
jindw 写道
没看到什么亮点。

#         public View create(HttpServletRequest req, HttpServletResponse resp){ 
#                 String title=req.getParameter("title"); 
#                 String content=req.getParameter("content"); 

不能吧getParameter去掉吗?繁琐。

给个建议,http参数可以自动注入吗?
比如:
public String cteate(String title,String content,int pageSize,int[] otherParams){
}

编译的时候,参数名称可能被去掉,不过好像可以通过系统标注提醒编译器保留参数名称的。

 

我的山寨框架就有基本的参数绑定功能

http://stworthy.iteye.com/admin/blogs/367304

自动参数绑定,我来推广一下 Lite XML的JSEL 表达式引擎吧。

 

JSEL表达式引擎可以自动装配对象,吧一个parameterMap 直接装配到一个特定的JavaBean中。

功能和OGNL类似,但是,更加简单,呆上Lite XML合集,也就是100多K。

0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics