日期:2014-05-17  浏览次数:20843 次

求高人指点诡异的java代码,包证很多人没见过。90%没用过
无意在网上看到某个人发的一种写法, 这是什么写法那么怪异,而且是用txt文件,不是用java文件。但是内容确实是
java的呀。运用ssh框架术。不懂这个#{Entity}类似这种.请高人指点,这个从某种意义上来说是一种类的规范,像泛型的思想有点,只是不断的替换类名,其实架构还是不变,内容变。




import #{dao_p}.#{Entity}Dao;
import #{entity_p}.#{Entity};
import #{manager_p}.#{Entity}Mng;

@Service
@Transactional
public class #{Entity}MngImpl implements #{Entity}Mng {
@Transactional(readOnly = true)
public Pagination getPage(int pageNo, int pageSize) {
Pagination page = dao.getPage(pageNo, pageSize);
return page;
}

@Transactional(readOnly = true)
public #{Entity} findById(Integer id) {
#{Entity} entity = dao.findById(id);
return entity;
}

public #{Entity} save(#{Entity} bean) {
dao.save(bean);
return bean;
}

public #{Entity} update(#{Entity} bean) {
Updater<#{Entity}> updater = new Updater<#{Entity}>(bean);
bean = dao.updateByUpdater(updater);
return bean;
}

public #{Entity} deleteById(Integer id) {
#{Entity} bean = dao.deleteById(id);
return bean;
}

public #{Entity}[] deleteByIds(Integer[] ids) {
#{Entity}[] beans = new #{Entity}[ids.length];
for (int i = 0,len = ids.length; i < len; i++) {
beans[i] = deleteById(ids[i]);
}
return beans;
}

private #{Entity}Dao dao;

@Autowired
public void setDao(#{Entity}Dao dao) {
this.dao = dao;
}
}


------最佳解决方案--------------------
有点像 ibatis 里的实现 Dao 接口的
------其他解决方案--------------------

这是一个自定义的开发模板,利用一套自定义的引擎来自动生成代码。很多代码生成器都是这么做的。
------其他解决方案--------------------
EL(表达式语言)的运用吧。
不觉得很怪异。没用过倒是真的。
------其他解决方案--------------------
不懂的
------其他解决方案--------------------
引用:
EL(表达式语言)的运用吧。
不觉得很怪异。没用过倒是真的。


el表达式不是dollar符吗?
------其他解决方案--------------------
这个那里是el表达式= =。 ${xxx}这样才是。这个文件要通过某个框架才能运行的。就不懂是什么java技术了。
------其他解决方案--------------------
hibernate的注解的写法吧,搜索“hibernate 注解”即可找打答案。
------其他解决方案--------------------
= =。我一向是用注解的。难道我不懂= =,问题是这个文件本来就不是.class是.txt  
------其他解决方案--------------------
通过配置的方式自动生存service类,利用自定义类加载器加载这些业务类字节码,可以省去不少编码。不过缺点也蛮多的。

------其他解决方案--------------------
引用:
通过配置的方式自动生存service类,利用自定义类加载器加载这些业务类字节码,可以省去不少编码。不过缺点也蛮多的。


还请说详细点。缺点有哪些?
------其他解决方案--------------------
引用:
这个那里是el表达式= =。 ${xxx}这样才是。这个文件要通过某个框架才能运行的。就不懂是什么java技术了。