以下哪个标签实现了java中java switch default功能02 <c:if> <c:java switch default>02

当前位置:&&
本页文章导读:
&&&&?SpringMVC request生命周期&&&&&&
& & & & When the request leaves the browser, it carries information about what the&user is asking for. At very least, the request will be carrying the requested URL. But&it may also carry additional
data such as the inf.........&&&&?jsp中c标签的使用&&&&&&jsp中c标签的使用
核心标签库
&&&它是JSTL中的核心库,为日常任务提供通用支持,如显示和设置变量、重复使用一组项目、测试条件和其他操作(如导入和重定向Web内容)。Core标签.........&&&&?python django MySQLdb 连接 mysql 5.5 中文乱码问题的解决&&&&&&本来就想从网上抓取一些页面的内容,然后解析其中的一些正文,放到mysql数据里面。python抓取和解析页面查看一些教程,很快也就解决了。可是,之后的问题画了将近两天的时间才搞定。。.........
[1]SpringMVC request生命周期
&&&&来源:&互联网& 发布时间:&
& & & & When the request leaves the browser, it carries information about what the&user is asking for. At very least, the request will be carrying the requested URL. But&it may also carry additional
data such as the information submitted in a form by the user.
The first stop in the request’s travels is Spring’s DispatcherServlet . Like&most Java-based MVC frameworks, Spring MVC funnels requests through a single&front controller servlet. A front controller
is a common web-application pattern&where a single servlet delegates responsibility for a request to other components&of an application to perform the actual processing. In the case of Spring MVC,&DispatcherServlet is the front controller.
& & & & The DispatcherServlet’s job is to send the request on to a Spring MVC controller.&A controller is a Spring component that processes the request. But a typical&application may have several
controllers and DispatcherServlet needs help&deciding which controller to send the request to. So, the DispatcherServlet consults one or more handler mappings C to figure out where the request’s next stop will be. The handler mapping will pay particular attention
to the URL carried by the request when making its decision.
& & & & Once an appropriate controller has been chosen, DispatcherServlet sends the&request on its merry way to the chosen controller. D At the controller, the request&will drop off its payload (the
information submitted by the user) and patiently wait&for the controller to process that information. (Actually, a well-designed Controller&performs little or no processing itself and instead delegates responsibility for the&business logic to one or more service
The logic performed by a controller often results in some information that&needs to be carried back to the user and displayed in the browser. This information&is referred to as the model. But sending
raw information back to the user isn’t&sufficient—it needs to be formatted in a user-friendly format, typically HTML. For&that the information needs to be given to a view, typically a JSP.
& & & &So, the last thing that the controller will do is package up the model data and the&name of a view into a ModelAndView object. &It then sends the request, along with&its new ModelAndView parcel,
back to the DispatcherServlet. As its name implies,&the ModelAndView object contains both the model data as well as a hint to what view&should render the results.
& & & &So that the controller isn’t coupled to a particular view, the ModelAndView&doesn’t carry a reference to the actual JSP. Instead it only carries a logical name that&will be used to look up
the actual view that will produce the resulting HTML. Once&the ModelAndView is delivered to the DispatcherServlet, the DispatcherServlet&asks a view resolver to help find the actual JSP.&
& & & &Now that the DispatcherServlet knows which view will render the results, the&request’s job is almost over. Its final stop is at the view implementation (probably a&JSP) where it delivers the
model data. &With the model data delivered to the view,&the request’s job is done. The view will use the model data to render a page that will&be carried back to the browser by the (not-so-hard-working) response object.
摘自《 Manning Spring in action》
通过对SpringMVC中request生命周期的理解。我们就很容易记住如何来配置他了。
作者:changsheng 发表于 14:59:54 原文链接
阅读:12 评论:0 查看评论
[2]jsp中c标签的使用
&&&&来源:&互联网& 发布时间:&
jsp中c标签的使用
核心标签库
&&&它是JSTL中的核心库,为日常任务提供通用支持,如显示和设置变量、重复使用一组项目、测试条件和其他操作(如导入和重定向Web内容)。Core标签按功能可分为4种类型:
1&变量维护:
(1)&c:set&:设置变量值和对象属性。语法如下:
&&&&&&&&c:set&value=&值&&var=&变量名&&scope=&变量的作用域&&target=&对象名&&property=&&对象属性名&&&/c:set&
每种设置都有两种方式,总结起来,&c:set&的4种形式,如下所示:
a.&使用标记属性设置JSP变量
&c:set&value=&值&&var=&变量名&&scope=&作用域&/&
b.&使用标记体设置JSP变量
&c:set&var=&变量名&&scope=&作用域&&标记内容&/c:set&
c.&使用标记属性设置对象属性
&c:set&value=&变量名&&target=&对象名&&property=&对象属性名&/&
d.&使用标记体设置对象属性
&c:set&target=&对象名&&property=&作用域&&标记内容&/set&
(2)&c:remove&:在指定作用域范围内删除变量。语法如下:
&c:remove&var=&变量名&&scope=&作用域&/&
2&流程控制:分为条件标签和迭代标签。
条件标签:&c:if&&&c:choose&&&c:when&&&c:otherwise&
(1)&c:if&:与Java语言中的if语句的使用方法一样,但不能实现else的功能。
&&&&&&c:if&标签有两种语法形式,是以有无标记体来区分的。
&&&&&无标签体:
&&&&&&&&&&c:if&test=&测试条件&&var=&变量名&&[scope=&作用域&]/&
&&&&&有标签体:
&&&&&&&&&&c:if&test=&测试条件&&var=&变量名&&[scope=&作用域&]&
&&&&&&&&&&&&&&&标签体
&&&&&&&&&&/c:if&
带标记体的&c:if&
&c:if&test=&${user.visitCount!=0}&&欢迎光临&/c:if&
(2)&c:choose&&&c:when&&&c:otherwise&
&c:when&&&c:otherwise&无法单独使用,只能作为&c:choose&的子标签来使用。这三个标签组合起来实现Java中的switch语句的功能。语法如下:
&&&&&c:choose&
&&&&&c:when&test=&${user.class==’guest’}&&
&&&&&&&&标签体1
&&&&&/c:when&
&&&&&c:when&test=&${user.class==’vip’}&&
&&&&&&&&标签体2
&&&&&/c:when&&&&
&&&&&c:otherwise&
&&&&&&&&标签体3
&&&&&/c:otherwise&&&
&&&&&/c:choose&
迭代标签:&c:forEach&&&c:forTokens&
(1)&c:forEach&:用于遍历一个对象集合。
&&&&&c:forEach&var=&变量名&&items=&集合&&varStatus=&遍历状态名&
&&&&&&&&&&&&&&&begin=&begin&&end=&end&&step=&step&&&
&&&&&&&&&&&&标签体&&&&&&&&&&
&&&&&/c:forEach&
(2)&c:forTokens&:用于遍历字符串,而且每次遍历结果返回字符串中的一个单词。
&&&&&c:forTokens&items=&字符串&&delims=&分界符&&var=&变量名&
&&&&&&&&&&varStatus=&遍历状态名&&begin=&begin&&end=&end&&step=&sep&&
&&&&&&&&&&&&标签体&&&&&
&&&&&/c:forTokens&
(1)&c:url&:用于对URL地址进行编码。
&&&&有标签体:
&&&&c:url&value=&URL&&context=&路径&&var=&变量名&&scope=&作用域&&
&&&&&&标签体
如下代码:
&c:url&value=&http://localhost:8080/el/index.jsp&&var=&NewURL&&
&&&&&&&c:param&name=&name&&value=&zero&/&
&&&&&&&c:param&name=&age&&value=&28&/&
&a&href=&${NewURL}&&点我呀&/a&
生成的URL:http://localhost:8080/el/index.jsp?name=zero&age=28
&&&无标签体:主要用于编辑上下文URL。
&&&&c:url&value=&URL&&context=&路径&&var=&变量名&&scope=&作用域&/&
&&&&如下代码:
&&&&c:url&value=&/logon.jsp&&登录&/c:url&&&&&&&&&&
若当前路径为el,则输出为:/el/logon.jsp&&&
(2)&c:import&:向当前JSP页面中引入URL资源(可以是远程序站点上的资源)。Include指令和include动作不能向JSP页引入Web程序以外的资源,引入的资源必须位于当前Web程序中。
以String对象引入的语法:
&c:import&url=&地址&&context=&上下文路径&&var=&变量名&
&&&&scope=&作用域&&charEncoding=&字符集&&
&&&&&&&&标签体使用&c:param&
&/c:import&
如下代码:将外部资源引入到当前JSP页面中.
&c:import&url=&&&var=&myurl&&charEncoding=&gb2312&&
&/c:import&
&a&href=&${myurl&}&&地址&/a&
以Reader对象导入的语法:
&c:import&url=&地址&&context=&上下文路径&&varReader=&变量名&
&&&&scope=&作用域&&charEncoding=&字符集&&
&&&&&&&&标签体使用其它动作元素
&/c:import&
(3)&c:redirect&:用于HTTP重定向。
&&&无标签体:&
&c:redirect&url=&地址&&context=&上下文路径&/&
&c:redirect&url=&地址&&context=&上下文路径&&
&&&&&&&&c:param/&标签
&/c:redirect&
(4)&c:param&:只能嵌入到&c:url&、、&c:import&、&c:redirect&标签中作为子元素来使用。此标签主要用于设置URL中将要传入的参数。
&c:param&name=&名称&&value=&值&/&&
&c:param&name=&名称&&value=&值&&&
&&&&标签体
&/c:param&
4&其它标签:&c:out&、&c:catch&。
(1)&c:out&:在JSP页面中显示变量内容。
&c:out&value=&值&&escapeXml=&{true|false}&&default=&默认值&/&
&c:out&value=&值&&escapeXml=&{true|false}&&default=&默认值&&
&&&&标签体
default:&用于指定当value值为null时,应该输出的值。
escapeXml:&用于设置是否将&&&、&&&、&&&、&’&、&&&、这些字符进行转义。
escapeXml默认为true,表示发生转换。
&&&转换成&&lt&
&&&转换成&&gt&
&&&转换成&&amp&
&’&转换成&&#039&
&&&转换成&&#034&
(2)&c:catch&:用于处
[3]python django MySQLdb 连接 mysql 5.5 中文乱码问题的解决
&&&&来源:&互联网& 发布时间:&
本来就想从网上抓取一些页面的内容,然后解析其中的一些正文,放到mysql数据里面。python抓取和解析页面查看一些教程,很快也就解决了。可是,之后的问题画了将近两天的时间才搞定。。那就是中文编码的问题。
最开始出现的问题是,解析的数据已经放入到数据库当中,可是在dump出来的时候,发现全是乱码:
mysqldump -uroot -p --skip-opt database table &temp.sql
正文的部分全是乱码,于是我觉得应该是mysql编码的问题,但是插入数据的,数据库中的中文显示是正常的,或许从数据库中取出数据的时候,编码也出了问题。不管怎样,有一点是清楚的,就是整个过程中对于中文字符的编码方式是不统一的,否则不会出现类似的问题。
Mysql的编码
通过以下方式,查看mysql中一些编码方式:
mysql& SHOW VARIABLES LIKE 'character%';
+----------------------------------------+-------------------------
| Variable_name&|Value
+----------------------------------------+-------------------------
| character_set_client&| latin1
|character_set_connection | latin1
|character_set_database | utf8
| character_set_filesystem | binary
| character_set_results&|latin1
| character_set_server&|utf8
| character_set_system&|utf8
| character_sets_dir&|D:\mysql\share\charsets\
+----------------------------------------+-------------------------
8 rows in set (0.00 sec)
mysql&SHOW VARIABLES LIKE 'collation_%';
+---------------------------------------+------------------
| Variable_name&|Value
+---------------------------------------+------------------
| collation_connection&|latin1_swedish_ci
| collation_database&|utf8_general_ci
| collation_server&|utf8_general_ci
+--------------------------------------+------------------
3 rows in set (0.00 sec)
从中我们可以看出,整个编码中,不全是utf8编码的。这样就会造成一些问题,例如:我们抓取的中文是utf8编码的,然后传给mysql,但是mysql的connection和server都是latin1编码的,而表示utf8,于是提交的utf8中文内容,会先被latin1编码,然后再由utf8编码。如果这样的话,再用第三方软件访问数据库就会出现问题,例如用phpadmin等,访问的虽然是utf8内容,但是是由latin1编码过后的utf8字符,不免会出现问题。
解决的方式:当然就是编码统一,全部采用utf8编码方式。如何更改?这里只介绍mysql5.5 以上的修改方式,我的mysql是5.5.29的。修改方式如下:
打开mysql配置文件:sudovim /etc/f
最新技术文章:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!
(C)2012-,E-mail:www_169it_(请将#改为@)Java switch case - Java Tutorials -
Java switch case
Syntax : Switch Case in Java ProgrammingIt is alternative to else-if ladder.Switch Case Syntax is similar to – .Switch allows you to choose a block of statements to run from a selection of code, based on the return value of an expression.The expression used in the switch statement must return an int, a String, or an enumerated value.switch (expression) {
case value_1 :
statement(s);
case value_2 :
statement(s);
case value_n :
statement(s);
statement(s);
}Different Ways of Using Switch Case :Way 1 : Switch Case Using Integer Case Labelswitch (i) {
System.out.println("One player is playing this game.");
System.out.println("Two players are playing this game.");
System.out.println("Three players are playing this game.");
System.out.println("You did not enter a valid value.");
}Way 2 : Switch Using StringString name = "Pritesh";
switch (name) {
case "Pritesh" :
System.out.println("One player is playing this game.");
case "Suraj" :
System.out.println("Two players are playing this game.");
case "Raj" :
System.out.println("Three players are playing this game.");
System.out.println("You did not enter a valid value.");
}If you are coming from C/C++ then you must understand this concept that – Java Supports String Inside Case Label.Above program if used in C/C++ then it will give us compile time error.How Switch Case Statement is different in java from c programmingIn C Programming we were unable to write Case label of data type
‘String’. In java we can have String inside “Switch”.Live Example 1 : Choose Day of the Weekclass SwitchDate{
public static void main(String[] args){
int week = 3;
switch (week){
System.out.println("monday");
System.out.println("tuesday");
System.out.println("wednesday");
System.out.println("thursday");
System.out.println("friday");
System.out.println("saturday");
System.out.println("sunday");
System.out.println("Invalid week");
Programming}

我要回帖

更多关于 java中switch 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信