私の要件は、親jspにデータを入力したい、またはスプリングを使用してポップアップを閉じるときのように他のjspにある可能性があることです。私が直面した問題はポップを開くことができますが、値を送信した後、データは同じポップアップに入力されます。たとえば、ポップアップを開いたときに行ったことは、データの「Employee_Id」の値を送信しました。ポップアップ自体に入力されます春を使用して別のページにデータを入力する方法がわかりませんここに私のコードがあります
これは私のコントローラーです
package com.nousinfo.tutorial.controllers;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.nousinfo.tutorial.model.EmployeeForm;
import com.nousinfo.tutorial.service.impl.EmployeeServiceImpl;
import com.nousinfo.tutorial.service.model.EmployeeBO;
@Controller
@RequestMapping("/search")
public class SearchEmployeeController {
private EmployeeServiceImpl employeeServiceImpl;
public void setEmployeeServiceImpl(EmployeeServiceImpl employeeServiceImpl) {
this.employeeServiceImpl = employeeServiceImpl;
}
@RequestMapping(value = "/searchspring", method = RequestMethod.GET)
public String view() throws Exception {
return "Home";
}
@RequestMapping(value = "/searchPage", method = RequestMethod.GET)
public ModelAndView search(@Validated EmployeeForm employeeForm,
@RequestParam("selectedValue") String selectedValue)
throws Exception {
ModelAndView model = new ModelAndView();
if (selectedValue.equals("FindEmployeeById")) {
boolean x = true;
model.addObject("x", x);
}
if (selectedValue.equals("FindEmployeeByName")) {
boolean y = true;
model.addObject("y", y);
}
if (selectedValue.equals("FindByDepartmentId")) {
boolean z = true;
model.addObject("z", z);
}
model.setViewName("Search");
return model;
}
@RequestMapping(value = "/FindById", method = RequestMethod.GET)
public ModelAndView searchByEmpNo(
@ModelAttribute("employeeForm") EmployeeForm employeeForm)
throws Exception {
ModelAndView model = new ModelAndView();
model.addObject("employeeForm", employeeForm);
Integer i = (employeeForm.getEmployeeNumber());
EmployeeBO employeeBO = employeeServiceImpl.getEmployee(i);
System.out.println(employeeBO);
model.addObject("employeeBO", employeeBO);
model.addObject("block", "block");
model.setViewName("EmployeeDetail");
return model;
}
@RequestMapping(value = "/FindByName", method = RequestMethod.POST)
public ModelAndView searchByEmployeeName(
@ModelAttribute("employeeForm") EmployeeForm employeeForm) {
ModelAndView model = new ModelAndView();
model.addObject("employeeForm", employeeForm);
List<EmployeeBO> employeeBOs = employeeServiceImpl
.findEmployees(employeeForm.getFirstName());
model.addObject("listEmployeeBO", employeeBOs);
model.addObject("block", "block");
model.setViewName("EmployeeList");
return model;
}
これは私のjspページです
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<fmt:setBundle basename="ApplicationResources" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Employee Search Page</title>
<script type="text/javascript">
function doAllThese(url) {
if (url == 'FindById') {
document.form.action = "/EmployeeWebSpring/search/FindById";
}
if (url == 'FindByName') {
document.form.action = "/EmployeeWebSpring/search/FindByName";
}
if (url == 'FindByDeptNO') {
document.form.action = "/EmployeeWebSpring/search/FindByDeptNO";
}
}
function loadName(name) {
this.firstName = name;
window.location = 'http://localhost:8080/EmployeeWeb/GetEmployee?key1='
+ encodeURIComponent(firstName);
}
</script>
</head>
<body>
<form:form name="form" commandName="employeeForm" method="post">
<c:if test="${requestScope.x}">
<div id="div1">
Employee_ID:
<form:input path="employeeNumber" />
<input type="submit" name="method" value="FindById" id="FindById"
onclick="doAllThese(this.value)" />
</div>
</c:if>
<c:if test="${requestScope.y}">
<div id="div2" >
Employee_Name
<form:input path="firstName" />
<input type="submit" name="method" value="FindByName"
onclick="doAllThese(this.value)" /> <br /> <font size=3>For
Searching the employees by<b>Employee Name</b><br />you can use %
match all the records with the given pattern
</font><br /> <font size="2"> <i>e.g <b> for search by</b>EmployeeName<br />
matches alL the employees whose name starts with character <b>S</b></i></font>
</div>
</c:if>
<c:if test="${requestScope.z}">
<div id="div3">
Employee_Name
<form:input path="departmentId" />
<input type="submit" name="method" value="FindByDeptNO"
onclick="doAllThese(this.value)" />
</div>
</c:if>
</form:form>
</body>
</html>
これは私のds-servlet xmlで、内部ビューリゾルバーを使用しています
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<context:annotation-config />
<mvc:annotation-driven />
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource"
id="dataSource">
<property value="com.mysql.jdbc.Driver" name="driverClassName" />
<property value="jdbc:mysql://192.168.25.30:3306/employee"
name="url" />
<property value="hr" name="username" />
<property value="hr123" name="password" />
</bean>
<bean id="employeeDaoImpl" class="com.nousinfo.tutorial.employee.dao.impl.EmployeeDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="employeserviceImpl" class=" com.nousinfo.tutorial.service.impl.EmployeeServiceImpl">
<property name="daoImpl" ref="employeeDaoImpl" />
</bean>
<bean id="mycontroller"
class="com.nousinfo.tutorial.controllers.SearchEmployeeController">
<property name="employeeServiceImpl" ref="employeserviceImpl"></property>
</bean>
<bean id="emplController" class="com.nousinfo.tutorial.controllers.EmployeeController">
<property name="employeeServiceImpl" ref="employeserviceImpl"></property>
</bean>
<bean id="configurationLoader"
class="org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader" />
<bean id="validator" class="org.springmodules.validation.bean.BeanValidator"
p:configurationLoader-ref="configurationLoader" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/" p:suffix=".jsp" />
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="com/nousinfo/resources/messages" />
</bean>
<!-- Configure the multipart resolver -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
</bean>