1,页面中点击一个按钮,清空file框中的值:
注:<input name=”
fileText” type=”file”/>
onClick="
fileText.select();document.selection.clear();"
2,页面中,让一个img的图片显示小手的标志
<img style=”cursor:pointer” src=”” />
3,页面中直接用DAO层的方法(注解)
<
s:bean name="com.dingxun.tiku.dao.impl.TopicCarDaoImpl" id="topicCarDao"></s:bean>
<s:set name=
"topicSize" value=
"#topicCarDao.findTopicSize(topicId,#session.userbean.frontUserId)"></s:set>
<span class="
carCheckBox
<s:property value='topicId'/>">
<s:if test=
"#topicSize>0">
<input type=
"checkbox" class=
"checkTopic" id=
"checkTopic" name=
"checkTopic" value=
"<s:property value=
'topicId'/>
" disabled>
</s:if>
<s:else> <input type=
"checkbox" name=
"checkTopic" value=
"<s:property value=
'topicId'/>
" > </s:else>
</sapn>
页面中的
jquery
中的使用
function addToCar(tId){
var topicId = tId;
$.ajax({
type: "POST",
url: "<%=pathstep1 %>/ManualPaperAjaxAction/save.action",
data: "topicId="+topicId,
cache: false,
success: function(msg){
$('.carMes'+tId).html("<input name='Submit' type='button' value='已入试题篮' disabled='disabled' class='btOrange'>");
$('.carCheckBox'+tId).html('<input type="checkbox" name="checkTopic" value="+tId+" disabled>');
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert(errorThrown);
alert(textStatus);
}
});}
4,页面中显示文本,可以直接截取:
例子:<s:if
test="topicInfo.topic.length()>80">
<s:property
value="topicInfo.topic.substring(0,80)" /><strong>. . . . . .</strong>
</s:if>
5,K736(21:03 - 12:59)
洛阳-洛阳东-偃师-巩义-郑州-开封-兰考-民权-商丘-徐州-蚌埠-南京-镇江-常州-无锡-苏州-上海
6,拿出页面的一个数组,或者同名的全部值。然后再动态的改变页面中的某些值。比如动态改变题目个数、分数。
function
countSum(){ //计算试卷题目总数
var countSum = 0;//题目总数
$(".order").each(function(i){//从class=”order”中拿出所有的值,然后循环
countSum = 0
countSum =i+1;
});
$('#topicSum').html(countSum);
}
function
scoreSum(){ //计算试卷题目总分
var scoreSum = 0;//试卷总分
$(".scoresList").each(function(i){
scoreSum += this.value*1;
});
$('#topicScoreSum').html(scoreSum);
}
<span
class="order" > </span>-------------------
5.注解
Service-------------------------------------------------
public
interface ITopicService {
public
void
saveTopic(TopicInfo topicInfo);
}
ServiceImpl--------------------------------------------
@Service
@Transactional
public
class TopicServiceImpl
implements ITopicService {
@Autowired
private ITopicDao topicDao;
@Override
public
void
saveTopic(TopicInfo topicInfo) {
topicDao.saveTopic(topicInfo);
}
}
Dao---------------------------------------------------
public
interface ITopicDao {
public
void
saveTopic(TopicInfo topicInfo);
}
DaoImpl------------------------------------------------
@Repository
public
class TopicDaoImpl
extends GenericDaoImpl<TopicInfo, String>
implements
ITopicDao {
@Autowired
private ITopicTypeDao topicTypeDao;
@Override
public
void
saveTopic(TopicInfo topicInfo) {
topicInfo.setUsetime(0);//使用次数设为0
topicInfo.setViewtime(0);//浏览次数设为0
this.save(topicInfo);
}
}
Action---------------------------------------------------------
@SuppressWarnings("serial")
@Scope("prototype")
@ParentPackage(value = "default")
@Namespace("/topic")
@Results( { @Result(name = "defaultOk", location = "/sysError/defaultOk.jsp"),
@Result(name = "defaultClose", location = "/sysError/defaultClose.jsp"),
@Result(name = "defaultError", location = "/sysError/defaultError.jsp") })
@InterceptorRefs( {
@InterceptorRef(value = "tokenSession", params = { "includeMethods",
"saveTopic" }), @InterceptorRef("defaultStack") })
public
class TopicAction
extends ActionSupport
implements TitleStatus{
@Autowired
private ITopicService
topicService;
/**
* 方法一(例子演示)
*
@return
*/
@Action(value = "topicList", results = {
@Result(name = "topicList", location = "/WEB-INF/topic/topicList.jsp") })
public String topicList() {
try{
List<TopicMes> topicMesList =
null;
newTopicMap =
new HashMap<Integer,List<TopicMes>>();
hotTopicMap =
new HashMap<Integer,List<TopicMes>>();
subjectList = subjectService.getSubjectList();//查找所有学科列表
for(SubjectInfo subject:subjectList){
topicMesList =
topicService.getNewTopics(subject.getSubjectId());//根据学科ID获得最新试题
newTopicMap.put(subject.getSubjectId(), topicMesList);//把学科ID和对应的最新试题放到Map中
}
for(SubjectInfo subject:subjectList){
topicMesList =
topicService.getHotTopics(subject.getSubjectId());//根据学科ID获得热门试题
hotTopicMap.put(subject.getSubjectId(), topicMesList);//把学科ID和对应的热门试题放到Map中
}
return "topicList";
}
catch(Exception e){
e.printStackTrace();
return "defaultError";
}
}