无法渲染子视图jsp以追加到主jsp中

时间:2013-11-14 12:52:11

标签: ajax spring-mvc

代码:

<script type="text/javascript">

   function gotoDetails(Name){
       $.ajax({
           type: "GET", 
           data:"Name="+Name,
           //dataType:"html",
           url: $("#empforecast").attr( "action"),
           success: function(response) { 
               alert("success");
               $('#expand_td').html(response); },
           error:function(e){alert("error");}   
       });

   }
   </script>

<div class="header"><h2>Employee Forecast Portal </h2></div>
<div class="mainbody">


            <table>
                <tr>
                    <td>Contract Name</td><td>Contract end date</td><td>No of employees</td><td>Forecast Amount</td>
                </tr>
                <c:forEach items="${conForecastList}" var="i">
                    <tr class="tab_heading">
                    <td><span onclick="gotoDetails('${i.Name}');">${i.Name}</span></td>
                    <td>${i.contractEndDate}
                    <span class="right_above" onclick="gotoDetails('${i.contractName}');">expand</span></td>
                    </tr>
                    <tr  style="display: none;" >
                    <td id="expand_td" colspan="4">

                    </td>
                    </tr>
                </c:forEach>
           </table>
</div>

</div>

Empforecast.jsp

                <tr>
                    <td>Employee Id</td><td>Employee Name</td><td>Level Of Employee</td><td>Niche Skill</td><td>Employee Location</td><td>Employee Rate</td>
                </tr>
                <c:forEach items="${List}" var="empList">
                <tr>
                    <td>empList.empID</td><td>empList.empName</td>
                </tr>
                </c:forEach>

@Controller
@SessionAttributes("username")

public class EmpForecastManagedBean {

      @Autowired
      ContractForecastEjbBean contractForecastEjbBean;

       private List<LoginModel> userList = new ArrayList<LoginModel>(); 
       private List<EmployeeForecastBean> empforecastInfoList= new ArrayList<EmployeeForecastBean>();
       private String contractName; 


      @RequestMapping(value="/empforecastpost",method = RequestMethod.GET,params = "Name")
      @ResponseBody
      public ModelAndView getContractForecast(@RequestParam("Name") String Name,@ModelAttribute("EmployeeForecastBean")
                  EmployeeForecastBean employeeForecastBean, BindingResult result) {
            try{
                  setList(contractForecastEjbBean.getEmpforContract(Name));
            }catch(Exception e){
                  System.out.println(e.getMessage());
            }
            return new ModelAndView("empforecast","List",List);
      }

0 个答案:

没有答案