1. Use of jstl labels:
(1) date output format: yyyy-mm-dd hh: mm: SS
<Display: column escapexml = "false" sortable = "true" titlekey = "videocomments. createtime">
<FMT: formatdate value = "$ {vclist. createtime}" type = "both" pattern = "yyyy-mm-dd hh: mm: SS"/>
</Display: column>
(2) display: Some attributes of table
<Display: Table name = "editorcommendlist. editorcommend" cellspacing = "0" cellpadding = "0" requesturi = ""
Id = "uclist" class = "table" Export = "true">
<Display: column escapexml = "false" sortable = "true" titlekey = "editorcommend. orderid">
<C: Out value = "$ {uclist_rownum}"/> displays the number of rows in the current row.
</Display: column>
<Display: column titlekey = "table. Op" style = "width: 20%" escapexml = "false" sortable = "false" Media = "html">
<Input type = "button" onclick = "location. href = '/edit.html? Videoid = <C: Out value = "$ {uclist. videoid}"/> & type = last '"style =" margin-Right: 5px"
Value = "<FMT: Message key =" button. Edit "/>"/> // you can specify videoid in a hyper-connection mode.
<Input type = "button" style = "margin-Right: 5px"
Onclick = "javascript: If (window. Confirm ('Are you sure ') location. href =
'<C: URL value = "/commend.html? Videoid =$ {uclist. videoid} & method = del "/> ';"
Value = "<FMT: Message key =" button. Delete "/>"/>
</Display: column>
</Display: Table>
2. Select a date in the format of yyyy-mm-dd hh: mm: Ss. the month and day do not contain "0x ".
<%
String STR = dateutil. getdate (new date (). substring (0, 11 );
// String [] arr = Str. Split ("-");
String year;
String Day;
String M = string. valueof (Str. charat (5 ));
If (M. Equals ("0 ")){
Month = Str. substring (6, 7 );
} Else {
Month = Str. substring (5, 7 );
}
String d = string. valueof (Str. charat (8 ));
If (D. Equals ("0 ")){
Day = Str. substring (9 );
} Else {
Day = Str. substring (8 );
}
String year = Str. substring (0, 4 );
%>
<C: Set Var = "Nian"> <% = year %> </C: Set>
<C: Set Var = "Ri"> <% = day %> </C: Set>
<C: Set Var = "Yue"> <% = month %> </C: Set>
<Select name = "year" size = "1" id = ">
<C: foreach Var = "year" begin = "2002" End = "2008" step = "1">
<Option <C: If test = "$ {year = Nian}"> selected </C: If> <C: out value = "$ {year}"/> </option>
</C: foreach>
</SELECT>
3. Convert characters to UTF-8
Public static string urlencoder (string STR, Boolean option ){
Try {
Return urlencoder. encode (STR, "UTF-8 ");
} Catch (exception e ){
If (option ){
Return STR;
} Else {
Return "";
}
}
}
4. Available and unavailable groupsearch buttons
<A href = "group.html? Type = 0 "onclick =" javascript: groupsearch. style. Display = 'none'; "> <FMT: Message key =" auditingcomments. Heading "/> </a> |
<A href = "group.html? Type = 1 "onclick =" javascript: groupsearch. style. Display = 'none'; "> <FMT: Message key =" defaultcomments. Heading "/> </a> |
<A href = "group.html? Type = <C: Out value = "$ {groupcommentslist. type} "/> & s = 1" onclick = "javascript: groupsearch. style. display = '';"> <FMT: Message key = "group. comments. search "/> </a>
5. Use js to determine the length of the text field
<HTML>
<Body>
<Form name = "testform">
<! -- <Textarea name = "A" Cols = "45" rows = "2"> AAAA </textarea>
<Input type = "button" onclick = "checkvalid ()" value = "Submit"> -->
<Textarea name = "A" Cols = "45" rows = "2" onkeydown = 'if (this. value. length> 4) {event. returnvalue = false} '> 1 </textarea>
<Input type = "Submit" value = "Submit">
</Form>
</Body>
</Html>
<Script language = "JavaScript">
Function checkvalid ()
{
VaR A = Document. testform.;
If (A. value. length> 4)
{
Alert ("the length of the input remarks box cannot exceed 20 characters! ");
Return false;
}
Return true;
}
</SCRIPT>
6. transcoding, from Chinese characters to UTF-8
Native2ascii 1. Properties> 2. Properties
7. Batch Delete
<C: Set Var = "buttons">
<C: Choose>
<C: When test = "$ {videocommentslist. type = '0'}">
<Input type = "button" onclick = "batchdel ();" value = "<FMT: Message key =" button. deletesome "/>"/>
</C: When>
<C: When test = "$ {videocommentslist. type = '1'}">
<Input type = "button" onclick = "batchdel ();" value = "<FMT: Message key =" relationvideo. Order. batch. Delete "/>"/>
</C: When>
</C: Choose>
</C: Set>
Function batchdel (){
If (! Checkrelationbox ()){
Alert ("Please select a checkbox! ");
} Else {
If (window. Confirm ('Are you sure ')){
Document. batchform. method. value = "batchdel ";
Document. batchform. P. value = 1;
Document. batchform. Submit ();
}
}
}
Function checkrelationbox (){
VaR element = Document. getelementsbyname ("commentsidbox ");
For (I = 0; I <element. length; I ++ ){
If (! Element [I]. Checked ){
VaR temp = Document. batchform. auditedid. value;
Document. batchform. auditedid. value = temp + "|" + element [I]. value;
}
}
Return true;
}
This method is available in the controller.
Public modelandview batchdel (httpservletrequest req, httpservletresponse res ){
If (log. isdebugenabled ()){
Log. debug ("video batch Delete .");
}
String view = messagecomments;
Int type = servletrequestutils. getintparameter (req, "type", 0 );
Int commentid = servletrequestutils. getintparameter (req, "commentid", 0 );
Int page = servletrequestutils. getintparameter (req, "P", 1 );
Int [] commentsidall = servletrequestutils. getintparameters (req, "commentsidbox ");
String auditedid = servletrequestutils. getstringparameter (req, "auditedid ","");
String returnstr = commentsmanager. videobatchdel (commentsidall );
String [] audited_id = stringutil. analyzestr (auditedid, "| ");
If (type = 0 ){
For (string currid: audited_id ){
Commentsmanager. dochangevideocomments (integer. parseint (currid), type );
}
}
Messagesourceaccessor text = new messagesourceaccessor (messagesource, req. getlocale ());
Return new modelandview (messagecomments, "retstr", text. getmessage (returnstr ));
}
Select All button
<Input type = "checkbox" name = "allbox1" value = "checkall" onclick = "checktheall (this)"/> <FMT: Message key = "videocomments. Check"/>
Function checktheall (theelement ){
For (VAR I = 0; I <document. batchform. commentsidbox. length; I ++ ){
Document. batchform. commentsidbox [I]. Checked = theelement. checked;
}
}
8. Determine whether the date meets the actual conditions:
Function checkdate (theelement, fieldname )...{
VaR S = theelement. value;
VaR filter =/^ (1 [6-9] | [2-9] d) d... {2})-(0? [1, 13578] | 1 [02])-(0? [1-9] | [12] d | 3 [01]) | (1 [6-9] | [2-9] d) d... {2})-(0? [13456789] | 1 [012])-(0? [1-9] | [12] d | 30) | (1 [6-9] | [2-9] d) d... {2})-0? 2-(0? [1-9] | 1D | 2 [0-8]) | (1 [6-9] | [2-9] D) (0 [48] | [2468] [048] | [13579] [26]) | (16 | [2468] [048] | [3579] [26]) 00)-0? 2-29-) $ /;
If (filter. test (s ))...{
Return true;
} Else ...{
Alert ("enter a valid" + fieldname + "! ");
Theelement. Focus ();
Return false;
}
}
Note that the format when calling is YYYY-MM-DD or month day can be a bit, etc. It is recommended to handle in advance to meet the YYYY-MM-DD format and then call this