发表于: 2017-11-11 10:50:15
1 858
今天完成的任务
试验了一下el表达式能够做到什么程度
首先我们可以知道el表达式可以做到的成都很多,甚至可以用java程序生成一个html在jsp中通过el表达式做出一个网页了
因为我图片路径的问题
正好在这里做一个试验看看
出现的结果
比较有意思的是
我们知道./是同级目录,../是上级目录
而直接在数据库输入${pageContext.request.contextPath}对于这样的路径是不行的
而虽然没有正确的显示路径,但是值得一提的是
中的
${pageContext.request.contextPath}是可以被编译的
在此百度没有得到答案仅作为小ties理解
----------------------------------------------------------------------------------------------------
动态sql语句
在categorymapper中添加如下语句
@SelectProvider(type=CategoryDynaSqlProvider.class,method="listOccDirAll")
public int listOccDirAll(Category category);//动态sql语句
在units中添加
CategoryDynaSqlProvider
public class CategoryDynaSqlProvider {
public String list() {
return new SQL()
.SELECT("*")
.FROM("student")
.toString();
}
public String listOccDirAll(){
return new SQL()
.SELECT("count(*)")
.FROM("student")
.WHERE("direction =#{direction} and occupation =#{occupation}")
.toString();
}
}
写了两个标签
虽然是动态sql的模子,但是并不灵活,仅作参考使用
---------------------------------------------------------------------------------------------------------
将两个页面布置到服务器上
地址放在成果展示里面,因为服务器太卡了,最多只能开两个web容器,这里关掉tomcat和resin用的jetty
有几个小问题值得说一下
1.t10根据student表来返回学习人数和工作人数
‘
2.t11页面
第一排是用c标签现实的
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
哎,我以为能教任务了,结果发现带spring的sql语句在web容器里面会出问题
现在做实验是怎么回事
做单变量的对照组,在controller继承接口后发现
@Select("select count(*) from student where direction = \"前端\" and occupation =#{occupation}")
public int listOccDir1(Category category);//查询职业人数
@Select("select count(*) from student where direction =#{direction} and occupation =\"web\"")
public int listOccDir2(Category category);//查询职业人数
@Select("select count(*) from student where direction =\"前端\" and occupation =\"web\"")
public int listOccDir3(Category category);//查询职业人数
@Select("select count(*) from student where direction =\"前端\" and occupation =\"web\"")
public int listOccDir4();//查询职业人数
@Select("select count(*) from student where direction =\"前端\" ")
public int listOccDir5(Category category);//查询职业人数
@Select("select count(*) from student where occupation =\"web\"")
public int listOccDir6(Category category);//查询职业人数
@Select("select count(*) from student where direction =\"前端\" ")
public int listOccDir7();//查询职业人数
@Select("select count(*) from student where occupation =\"web\"")
public int listOccDir8();//查询职业人数
@Select("select count(*) from student where id =1")
public int listOccDir9();//查询职业人数
0
0
0
0
0
0
0
0
6
0
6
1
@Select("select count(*) from student where occupation =\"web\"")
public int listOccDir6(Category category);//查询职业人数
@Select("select count(*) from student where occupation =\"web\"")
public int listOccDir8();//查询职业人数
@Select("select count(*) from student where id =1")
public int listOccDir9();//查询职业人数
看来问题是在于中文字符没办法查询
但是不对的地方是我在idea启动是没问题的,怎么在web容器里就不行了呢
后面通过idea在编译后的class文件里发现
原来是maven打包war的时候,出现的字符码编译错误
<build>
<finalName>task4</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
添加如下字段解决。
我觉得国人学编程真的蛮苦的,文档看不懂,翻墙翻不动,莫名其妙就有点陷阱让你gg
这次放到本地成功
---------------------------------------------------------------------------
找到错误弄好一夜就过去
本来打算好好写写的 但是太晚就简短说了
1.成果展示的两个界面只有“首页”“职业”写了跳转到对应的页面
2.t11的第一个职业介绍栏是c标签遍历,第二个职业介绍栏是师兄你说的方法,学习人数和t10的人数是一个表的,第二个职业介绍栏的第六个职业的学习人数是用动态sql
遇到的问题 可爱的编码问题
收获 编码
评论