📄 addtikuaction.java
字号:
package com.lili.exam.action;
import org.apache.struts2.ServletActionContext;
import com.lili.common.exception.ExamException;
import com.lili.exam.pojo.CChoice;
import com.lili.exam.pojo.SelectOne;
import com.lili.exam.pojo.Subject;
import com.lili.exam.service.ExamService;
import com.lili.exam.service.ExamServiceImpl;
import com.lili.exam.util.BeanFactory;
import com.opensymphony.xwork2.ActionSupport;
public class AddtikuAction extends ActionSupport{
private String name;
private String question;
private String keya;
private String keyb;
private String keyc;
private String keyd;
private String answer;
private Double fenzhi;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public String getKeya() {
return keya;
}
public void setKeya(String keya) {
this.keya = keya;
}
public String getKeyb() {
return keyb;
}
public void setKeyb(String keyb) {
this.keyb = keyb;
}
public String getKeyc() {
return keyc;
}
public void setKeyc(String keyc) {
this.keyc = keyc;
}
public String getKeyd() {
return keyd;
}
public void setKeyd(String keyd) {
this.keyd = keyd;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public Double getFenzhi() {
return fenzhi;
}
public void setFenzhi(Double fenzhi) {
this.fenzhi = fenzhi;
}
public String addSelectOne(){
ExamService service = (ExamServiceImpl)BeanFactory.getBean("examService");
try {
System.out.println("addtikuAction : addSelectOne "+name+" : "+keya+" : "+fenzhi);
Subject subject = service.getSubjectByName(name);
System.out.println("==============: "+subject);
SelectOne s = new SelectOne();
s.setQuestion(question);
s.setKeya(keya);
s.setKeyb(keyb);
s.setKeyc(keyc);
s.setKeyd(keyd);
s.setFenzhi(fenzhi);
s.setAnswer(answer);
s.setSubject(subject);
service.saveOrUpdateSelectOne(s);
ServletActionContext.getRequest().setAttribute("s_message", "添加选择题成功!");
return SUCCESS;
} catch (ExamException e) {
// TODO Auto-generated catch block
e.printStackTrace();
e.getMessage();
return ERROR;
}
}
public String addChoice(){
ExamService service = (ExamServiceImpl)BeanFactory.getBean("examService");
try{
System.out.println(name+" **********");
System.out.println("addtikuAction : addChoice "+name+" : "+answer+" : "+fenzhi);
Subject subject = service.getSubjectByName(name);
CChoice c = new CChoice();
c.setAnswer(answer);
c.setQuestion(question);
c.setFenzhi(fenzhi);
c.setSubject(subject);
service.saveOrUpdateChoice(c);
ServletActionContext.getRequest().setAttribute("c_message", "添加判断题成功!");
return SUCCESS;
}catch(Exception e){
e.printStackTrace();
e.getMessage();
return ERROR;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -