package Test.code;
import java.io.File;
import java.io.FileWriter;
import Test.TestUtil;
public class ControllerTest {
public static void controllerTest(String tableName,String tableBean,String currentBao) throws Exception{
String rn = "\r\n";
String []array = TestUtil.stringToArray(tableBean);
String src =
"package " + currentBao + ".controller;"+ rn+
rn +
"import java.util.List;"+ rn+
"import javax.servlet.http.HttpSession;"+ rn+
"import org.springframework.beans.factory.annotation.Autowired;"+ rn+
"import org.springframework.stereotype.Controller;"+ rn+
"import org.springframework.ui.ModelMap;"+ rn+
"import org.springframework.web.bind.annotation.PathVariable;"+ rn+
"import org.springframework.web.bind.annotation.RequestMapping;"+ rn+
"import org.springframework.web.bind.annotation.RequestMethod;"+ rn+
rn +
"import " + currentBao + ".bean."+TestUtil.upperFirstChar(tableName)+ ";"+ rn+
"import " + currentBao + ".service."+TestUtil.upperFirstChar(tableName)+ "Service;"+ rn+
rn +
"@Controller"+ rn+
"public class "+TestUtil.upperFirstChar(tableName)+ "Controller {"+ rn+
rn +
" @Autowired"+ rn+
" "+TestUtil.upperFirstChar(tableName)+ "Service service;"+ rn+
rn +
" @RequestMapping(value = \"/"+tableName+"View.do\")"+ rn+
" public String "+tableName+"View(ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" List<"+TestUtil.upperFirstChar(tableName)+"> "+tableName+"List = service.all"+TestUtil.upperFirstChar(tableName)+"();"+ rn+
" modelMap.put(\""+tableName+"List\", "+tableName+"List);"+ rn+
" return \"back/jsp/"+tableName+"/"+tableName+"View\";"+ rn+
" }"+ rn+
rn +
" @RequestMapping(value = \"/"+tableName+"Del{"+array[0]+"}.do\")"+ rn+
" public String "+tableName+"Del(@PathVariable(\""+array[0]+"\")int "+array[0]+" ,ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" service.del"+TestUtil.upperFirstChar(tableName)+"("+array[0]+");"+ rn+
" String message1=\"删除成功\";"+ rn+
" String message2=\"请返回……\";"+ rn+
" String url=\""+tableName+"View.do\";"+ rn+
" modelMap.put(\"message1\", message1);"+ rn+
" modelMap.put(\"message2\", message2);"+ rn+
" modelMap.put(\"url\", url);"+ rn+
" return \"infomationShow\";"+ rn+
" }"+ rn+
rn +
" @RequestMapping(value =\"/"+tableName+"GoAdd.do\")"+ rn+
" public String "+tableName+"GoAdd(ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" return \"back/jsp/"+tableName+"/"+tableName+"Add\";"+ rn+
" }"+ rn+
rn +
" @RequestMapping(value = \"/"+tableName+"Add.do\",method=RequestMethod.POST)"+ rn+
" public String "+tableName+"Add("+TestUtil.upperFirstChar(tableName)+" form,ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" service.add"+TestUtil.upperFirstChar(tableName)+"(form);"+ rn+
" String message1=\"添加成功\";"+ rn+
" String message2=\"请返回……\";"+ rn+
" String url=\""+tableName+"View.do\";"+ rn+
" modelMap.put(\"message1\", message1);"+ rn+
" modelMap.put(\"message2\", message2);"+ rn+
" modelMap.put(\"url\", url);"+ rn+
" return \"infomationShow\";"+ rn+
" }"+ rn+
rn +
" @RequestMapping(value = \"/"+tableName+"GoUpdate{"+array[0]+"}.do\")"+ rn+
" public String "+tableName+"GoUpdate(@PathVariable(\""+array[0]+"\")int "+array[0]+" ,ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" "+TestUtil.upperFirstChar(tableName)+" "+tableName+" = service."+tableName+"("+array[0]+");"+ rn+
" modelMap.put(\""+tableName+"\", "+tableName+");"+ rn+
" return \"back/jsp/"+tableName+"/"+tableName+"Update\";"+ rn+
" }"+ rn+
rn+
" @RequestMapping(value = \"/"+tableName+"Update.do\",method=RequestMethod.POST)"+ rn+
" public String "+tableName+"Update("+TestUtil.upperFirstChar(tableName)+" form,ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" service.update"+TestUtil.upperFirstChar(tableName)+"(form);"+ rn+
" String message1=\"修改成功\";"+ rn+
" String message2=\"请返回……\";"+ rn+
" String url=\""+tableName+"View.do\";"+ rn+
" modelMap.put(\"message1\", message1);"+ rn+
" modelMap.put(\"message2\", message2);"+ rn+
" modelMap.put(\"url\", url);"+ rn+
" return \"infomationShow\";"+ rn+
" }"+ rn+
rn +
"}"+ rn ;
String path = System.getProperty("user.dir")+"/src/"+TestUtil.docToBackslash(currentBao)+"/controller/";
File fpath = new File(path);
if (!fpath.exists()) {
fpath.mkdirs();
}
String fileName = System.getProperty("user.dir")+"/src/"+TestUtil.docToBackslash(currentBao)+"/controller/"+TestUtil.upperFirstChar(tableName)+"Controller.java";
File f = new File(fileName);
FileWriter fw = new FileWriter(f);
fw.write(src);
fw.flush();
fw.close();
}
public static void controllerTest_(String tableName,String firstTable,String tableBean,String currentBao) throws Exception{
String rn = "\r\n";
String []array = TestUtil.stringToArray(tableBean);
String src =
"package " + currentBao + ".controller;"+ rn+
rn +
"import java.util.List;"+ rn+
"import javax.servlet.http.HttpSession;"+ rn+
"import org.springframework.beans.factory.annotation.Autowired;"+ rn+
"import org.springframework.stereotype.Controller;"+ rn+
"import org.springframework.ui.ModelMap;"+ rn+
"import org.springframework.web.bind.annotation.PathVariable;"+ rn+
"import org.springframework.web.bind.annotation.RequestMapping;"+ rn+
"import org.springframework.web.bind.annotation.RequestMethod;"+ rn+
rn +
"import " + currentBao + ".bean."+TestUtil.upperFirstChar(tableName)+ ";"+ rn+
"import " + currentBao + ".service."+TestUtil.upperFirstChar(tableName)+ "Service;"+ rn+
rn +
"@Controller"+ rn+
"public class "+TestUtil.upperFirstChar(tableName)+ "Controller {"+ rn+
rn +
" @Autowired"+ rn+
" "+TestUtil.upperFirstChar(tableName)+ "Service service;"+ rn+
rn +
" @RequestMapping(value = \"/"+tableName+"View{"+firstTable+"Id}.do\")"+ rn+
" public String "+tableName+"View(@PathVariable(\""+firstTable+"Id\")String "+firstTable+"Id ,ModelMap modelMap,String pageNo, String choice, HttpSession session){"+ rn+
" List<"+TestUtil.upperFirstChar(tableName)+"> "+tableName+"List = service.all"+TestUtil.upperFirstChar(tableName)+"("+firstTable+"Id);"+ rn+
" "+TestUtil.upperFirstChar(tableName)+" "+tableName+" = new "+TestUtil.upperFirstChar(tableName)+"(); "+ rn+
" "+tableName+".set"+TestUtil.upperFirstChar(firstTable)+"Id("+firstTable+"Id);"+ rn+
" modelMap.put(\""+tableName+"\", "+tableName+");"+ rn+
" modelMap.put(\""+tableName+"List\", "+tableName+"List);"+ rn+
" return \"back/jsp/"+tableName+"/"+tableName+"View\";"+ rn+
" }"+ rn+
rn +
" @RequestMapping(value = \"/"+tableNa
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
mybatis+mysql+springmvc + multidatasource+Atomikos 多数据源 (可以跑通的) http://knight-black-bob.iteye.com/blog/2253726
资源推荐
资源详情
资源评论
收起资源包目录
mybatis+mysql+springmvc + multidatasource+Atomikos 多数据源 (142个子文件)
ControllerTest.class 8KB
SJView.class 7KB
FJView.class 6KB
JSPViewTest.class 6KB
MapperTest.class 6KB
SJUpdate.class 5KB
SJAdd.class 5KB
FJUpdate.class 5KB
JSPUpdateTest.class 5KB
FJAdd.class 4KB
JSPAddTest.class 4KB
ServiceTest.class 4KB
UserController.class 4KB
JSPLeftTest.class 4KB
DaoTest.class 3KB
BeanTest.class 3KB
JSPMainTest.class 3KB
JSPRightTest.class 2KB
AutoTest.class 2KB
User.class 1KB
User2Service.class 1KB
UserService.class 1KB
TestUtil.class 1KB
DatabaseContextHolder.class 984B
DataSourceInterceptor.class 860B
TestConfig.class 649B
DynamicDataSource.class 562B
User2Dao.class 357B
UserDao.class 355B
.classpath 4KB
org.eclipse.wst.common.component 474B
org.eclipse.wst.jsdt.ui.superType.container 49B
xalan.jar 3MB
aspectjweaver.jar 1.47MB
org.springframework.context-3.1.0.RC1.jar 788KB
mysql-connector-java-5.1.17-bin.jar 769KB
mybatis-3.0.6.jar 630KB
mchange-commons-java-0.2.8.jar 589KB
org.springframework.beans-3.1.0.RC1.jar 573KB
org.springframework.web.servlet-3.1.0.RC1.jar 550KB
org.springframework.web-3.1.0.RC1.jar 526KB
c3p0-0.9.5.jar 477KB
mail-1.4.1.jar 437KB
antlr-2.7.6.jar 433KB
org.springframework.core-3.1.0.RC1.jar 429KB
jstl-1.2.jar 405KB
org.springframework.jdbc-3.1.0.RC1.jar 392KB
log4j-1.2.15.jar 383KB
org.springframework.aop-3.1.0.RC1.jar 324KB
jcommon-1.0.12.jar 301KB
commons-httpclient-3.0.1.jar 273KB
org.springframework.transaction-3.1.0.RC1.jar 241KB
commons-lang.jar 237KB
org.springframework.expression-3.1.0.RC1.jar 172KB
commons-io-2.0.1.jar 156KB
transactions-3.7.0.jar 153KB
commons-dbcp.jar 119KB
aspectjrt.jar 112KB
transactions-jta-3.7.0.jar 109KB
org.springframework.context.support-3.1.0.RC1.jar 98KB
thumbnailator-0.4.2.jar 89KB
atomikos-util-3.7.0.jar 86KB
activation-1.1.jar 62KB
commons-pool.jar 61KB
commons-logging.jar 59KB
commons-fileupload-1.2.2.jar 58KB
org.springframework.asm-3.1.0.RC1.jar 52KB
org.springframework.aspects-3.1.0.RC1.jar 47KB
commons-codec-1.3.jar 46KB
transactions-jdbc-3.7.0.jar 37KB
mybatis-spring-1.0.2.jar 34KB
transactions-api-3.7.0.jar 27KB
asm.jar 26KB
slf4j-api-1.5.0.jar 16KB
cfgatewayadapter.jar 15KB
swtgraphics2d.jar 14KB
slf4j-log4j12-1.5.0.jar 9KB
aopalliance.jar 4KB
ControllerTest.java 12KB
MapperTest.java 7KB
SJView.java 6KB
FJView.java 5KB
ServiceTest.java 5KB
JSPViewTest.java 5KB
AutoTest.java 4KB
SJUpdate.java 4KB
SJAdd.java 4KB
FJUpdate.java 4KB
JSPUpdateTest.java 4KB
DaoTest.java 4KB
JSPAddTest.java 3KB
FJAdd.java 3KB
UserController.java 3KB
JSPLeftTest.java 3KB
BeanTest.java 2KB
JSPMainTest.java 2KB
JSPRightTest.java 1KB
User.java 1KB
TestUtil.java 787B
User2Service.java 713B
共 142 条
- 1
- 2
资源评论
- tab18882015-11-06太简单了,不完整
- sssssssssafw2016-09-27太简单了,不完整
- dreamwhere842018-12-11太简单了,不完整
curiousby
- 粉丝: 23
- 资源: 151
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功