我正在尝试使用Hibernate将数据库记录显示到Struts 2中的JSP页面.我成功完成了检索部分.
但无论我做什么,我似乎都无法在JSP页面中显示数据.
我试过在互联网上找到各种解决方案.但是无法理解什么似乎是问题所在.我可以看到表列名,但其中没有数据.我在User POJO课程中拥有所有必需的getter和setter.
我附上了我的代码:
注册行动:
public class RegisterAction extends ActionSupport{
String name,pwd,email,address;
int phno;
public RegisterAction() {}
List<User> users = new ArrayList<User>();
UserDao udao = new UserDao();
//Getters and setters.
public String execute() throws Exception {
User u=new User();
u.setName(name);
u.setEmail(email);
u.setAddress(address);
u.setPhno(phno);
u.setPwd(pwd);
udao.addUser(u);
return "success";
}
public String listAllUsers(){
users = udao.getUsers();
System.out.println("In Action, "+users);
return "success";
}
}
Run Code Online (Sandbox Code Playgroud)
UserDao:
public class UserDao{
List<User> allUsers = new ArrayList<User>();
public UserDao() {}
//Getter and setter.
public …Run Code Online (Sandbox Code Playgroud) 我有一个SQL问题.我在图像中有3个表格.在前端(用户界面),我有一个selectone框来选择课程和员工自动完成.自动填充必须检索所有员工姓名以及所选课程的状态.

我试过了
select e.id,per.id,t.status
from employee e
join person per on e.personId=per.id
left join training t on e.id=t.employeeId`
Run Code Online (Sandbox Code Playgroud)
但是这会检索employeeId'1'的重复行.对于id为1的员工,我需要仅使用所选的courseId(从用户界面中选择)退出行.
简而言之,我需要所有员工的信息以及所选择的课程员工信息,而且我也不能重复这些信息.
如果选择的课程ID为34,则检索的输出必须包含
Empid,PersonName,Status
1, Ravi , 1;
2, Meera , 0;
3, Rahul ,0;
4, Vinu, 0.
Run Code Online (Sandbox Code Playgroud)
我如何形成reqd sql查询?
根据提供的建议,我将接受的答案修改为(根据我的要求)
SELECT e.id,per.name,COALESCE(t.status,0)
FROM employee e
JOIN person per ON e.personId=per.id
LEFT JOIN training t ON e.id=t.employeeId
AND t.courseId = ?
Run Code Online (Sandbox Code Playgroud) 我有一个jsf spring应用程序并使用mockito进行单元测试.NullPointerException当我junit在iEmployeeService模拟中运行我的测试时,我不断得到.有没有Exception进行iSecurityLoginService.
被嘲笑的方法
@Autowired
IEmployeeService iEmployeeService;
@Autowired
ISecurityLoginService iSecurityLoginService;
public void addEvent() {
entityEventsCreate.setTitle(entityEventsCreate.getTitle());
entityEventsCreate.setModifiedBy(iSecurityLoginService
.findLoggedInUserId());
int eventId = iEmployeeService.addEmployeeTimeOff(entityEventsCreate);
}
Run Code Online (Sandbox Code Playgroud)
我的JUnit测试用注释 @RunWith(MockitoJUnitRunner.class)
@Mock
ISecurityLoginService iSecurityLoginService;
@Mock
IEmployeeService iEmployeeService;
@InjectMocks
ServiceCalendarViewBean serviceCalendarViewBean = new ServiceCalendarViewBean();
@Before public void initMocks() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testSaveEvent() {
Mockito.when(iSecurityLoginService.findLoggedInUserId()).thenReturn(1);
serviceCalendarViewBean.getEntityEventsCreate().setTitle("Junit Event Testing");
Mockito.when(iSecurityLoginService.findLoggedInUserId()).thenReturn(1);
Mockito.when(iEmployeeService.addEmployeeTimeOff(Mockito.any(Events.class))).thenReturn(2);
serviceCalendarViewBean.addEvent();
}
Run Code Online (Sandbox Code Playgroud) 我有文件(组件树)'m',我试图存储在html5的本地存储中.我尝试将其设置为本地存储.但当我将其取回时,此m已更改为[object Document].如何将文档存储到本地存储并将其作为文档本身检索?
以下是我尝试过的代码


应用程序向服务器发送ajax请求以退出日历的事件,并在请求的onsuccess中收到xhtml的dom表示.当用户进入下周视图时,应用程序必须从本地存储中撤消该事件.要从js文件向客户端发送响应,dom表示也是必要的.因此我们需要将dom表示存储到localstorage.
我的要求是在第一张图片的控制台,您可以看到从文档m中检索到'k'并作为响应发送到客户端.所以,我想要的是将此k或m存储到本地存储,以便我可以操作它在同一个js文件中.这个代码位于一个单独的js文件中,该文件在xhtml文件中使用.
我正在使用primefaces 4.0,jsf 2.1.
当我使用
localStorage.setItem( "calendarevents",JSON.stringify(K));
我得到一个错误'将循环结构转换为json'.
我试图将选定的文件从本地文件系统上传到应用程序中的文件夹.这里使用的技术是jsp,servlet.
单击Example.jsp的Press按钮,控件将传递给Request servlet.但检查如果请求是多部分则返回false.所以"抱歉这个Servlet只处理文件上传请求"打印在控制台中.
Example.jsp
<form action="Request" method="Post" name = "invoices" target="_self">
<div class="invoicetable">
<table>
<colgroup>
<col class="first" span="1">
<col class="rest" span="1">
</colgroup>
<tr>
<td>Start date:</td>
<td><input type = "text" name = "start_date" id="datepicker" size = "6" maxlength="10"/></td>
</tr>
<tr>
<td>End date:</td>
<td><input type = "text" name = "end_date" id="datepicker2" size = "6" maxlength="10"/></td>
</tr>
<tr>
<form action="Request" enctype="multipart/form-data" method="post" name = "upload">
<table>
<tr>
<td>Input File:</td>
<td><input type = "file" name ="datafile" size="30" maxlength="200"/></td>
</tr>
</table>
<div>
<input type ="submit" …Run Code Online (Sandbox Code Playgroud)