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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
www.baoy.com简洁版.rar (88个子文件)
www.baoy.com
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.wst.common.component 474B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 493B
org.eclipse.jdt.core.prefs 395B
src
Test
TestUtil.java 787B
TestConfig.java 628B
AutoTest.java 4KB
code
ControllerTest.java 12KB
MapperTest.java 7KB
BeanTest.java 2KB
ServiceTest.java 5KB
DaoTest.java 4KB
jsp
hasconn
containsecond
SJUpdate.java 4KB
SJView.java 6KB
FJUpdate.java 4KB
SJAdd.java 4KB
FJView.java 5KB
FJAdd.java 3KB
common
JSPLeftTest.java 3KB
JSPRightTest.java 1KB
JSPMainTest.java 2KB
noconn
JSPUpdateTest.java 4KB
JSPViewTest.java 5KB
JSPAddTest.java 3KB
.project 2KB
WebRoot
META-INF
MANIFEST.MF 36B
WEB-INF
test-servlet.xml 2KB
web.xml 724B
classes
Test
AutoTest.class 2KB
code
ControllerTest.class 8KB
DaoTest.class 3KB
BeanTest.class 3KB
ServiceTest.class 4KB
MapperTest.class 6KB
jsp
hasconn
containsecond
SJAdd.class 5KB
FJView.class 6KB
SJView.class 7KB
FJUpdate.class 5KB
SJUpdate.class 5KB
FJAdd.class 4KB
common
JSPLeftTest.class 4KB
JSPRightTest.class 2KB
JSPMainTest.class 3KB
noconn
JSPUpdateTest.class 5KB
JSPViewTest.class 6KB
JSPAddTest.class 4KB
TestUtil.class 1KB
TestConfig.class 649B
lib
jcommon-1.0.12.jar 301KB
slf4j-log4j12-1.5.0.jar 9KB
thumbnailator-0.4.2.jar 89KB
commons-codec-1.3.jar 46KB
org.springframework.aspects-3.1.0.RC1.jar 47KB
mybatis-3.0.6.jar 630KB
org.springframework.aop-3.1.0.RC1.jar 324KB
swtgraphics2d.jar 14KB
commons-io-2.0.1.jar 156KB
commons-httpclient-3.0.1.jar 273KB
org.springframework.expression-3.1.0.RC1.jar 172KB
org.springframework.web.servlet-3.1.0.RC1.jar 550KB
org.springframework.jdbc-3.1.0.RC1.jar 392KB
activation-1.1.jar 62KB
org.springframework.asm-3.1.0.RC1.jar 52KB
mail-1.4.1.jar 437KB
mysql-connector-java-5.1.17-bin.jar 769KB
org.springframework.transaction-3.1.0.RC1.jar 241KB
xalan.jar 3MB
commons-logging.jar 59KB
org.springframework.web-3.1.0.RC1.jar 526KB
commons-pool.jar 61KB
commons-fileupload-1.2.2.jar 58KB
slf4j-api-1.5.0.jar 16KB
jstl-1.2.jar 405KB
commons-dbcp.jar 119KB
mybatis-spring-1.0.2.jar 34KB
log4j-1.2.15.jar 383KB
org.springframework.core-3.1.0.RC1.jar 429KB
org.springframework.beans-3.1.0.RC1.jar 573KB
org.springframework.context.support-3.1.0.RC1.jar 98KB
commons-lang.jar 237KB
org.springframework.context-3.1.0.RC1.jar 788KB
cfgatewayadapter.jar 15KB
index.jsp 834B
forword
css
js
jsp
infomationShow.jsp 1KB
.mymetadata 309B
.classpath 3KB
.myeclipse
共 88 条
- 1
资源评论
curiousby
- 粉丝: 23
- 资源: 151
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功