Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 控制器未分派请求的视图_Spring - Fatal编程技术网

Spring 控制器未分派请求的视图

Spring 控制器未分派请求的视图,spring,Spring,我是春天的新手。运行程序后,我收到如下错误 -名为“dispatcher”的DispatcherServlet正在处理[/SpringLoginApp/save]的POST请求 -请求[/save]的匹配模式为[/**] -请求[/save]的URI模板变量为{} -使用handler-[org.springframework.web.servlet.resource将[/save]映射到HandlerExecutionChain。DefaultServletHttpRequestHandler

我是春天的新手。运行程序后,我收到如下错误

-名为“dispatcher”的DispatcherServlet正在处理[/SpringLoginApp/save]的POST请求 -请求[/save]的匹配模式为[/**] -请求[/save]的URI模板变量为{} -使用handler-[org.springframework.web.servlet.resource将[/save]映射到HandlerExecutionChain。DefaultServletHttpRequestHandler@5771b5fa] 和1个拦截器-跳过CORS处理:请求来自同一来源 -返回给名为“dispatcher”的DispatcherServlet的Null ModelAndView:-假设HandlerAdapter已完成请求处理 -已成功完成请求

这是我要指挥的控制器

  @RequestMapping(value = "/save", method = RequestMethod.POST)

  public String saveEmployee(@ModelAttribute("command")EmployeeBean      
   employeeBean,  BindingResult result) 
 {
   Employee employee = prepareModel(employeeBean);
   employeeService.addEmployee(employee);
   return "redirect:/add";
 }

 @RequestMapping(value = "/add", method = RequestMethod.GET)
 public ModelAndView   addEmployee(@ModelAttribute("command")EmployeeBean employeeBean,BindingResult result)
 {
  Map<String, Object> model = new HashMap<String, Object>();
    model.put("employees",prepareListofBean(employeeService.listEmployeess()));
  return new ModelAndView("addEmployee", model);
 }
@RequestMapping(value=“/save”,method=RequestMethod.POST)
公共字符串saveEmployee(@ModelAttribute(“命令”)EmployeeBean
employeeBean,BindingResult)
{
Employee=prepareModel(employeeBean);
员工服务。添加员工(员工);
返回“重定向:/add”;
}
@RequestMapping(value=“/add”,method=RequestMethod.GET)
公共模型和视图addEmployee(@ModelAttribute(“命令”)EmployeeBean EmployeeBean,BindingResult)
{
映射模型=新的HashMap();
model.put(“employees”,prepareListofBean(employeeService.listEmployeess());
返回新模型和视图(“addEmployee”,模型);
}
这是我的调度员

<?xml version="1.0" encoding="UTF-8"?>
<beans  xmlns="http://www.springframework.org/schema/beans" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:tx="http://www.springframework.org/schema/tx" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc
                         http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
                         http://www.springframework.org/schema/beans
                         http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
                         http://www.springframework.org/schema/context
                         http://www.springframework.org/schema/context/spring-context-4.2.xsd
                         http://www.springframework.org/schema/tx
                         http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">  


 <context:property-placeholder location="classpath:resource/message.properties"/>

   <context:component-scan base-package="com.springLogin.*" />
   <tx:annotation-driven />
   <tx:annotation-driven transaction-manager="hibernateTransactionManager" />
   <mvc:default-servlet-handler/>
    <bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    id="viewResolver">
      <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView"></property>
      <property name="prefix" value="/WEB-INF/views"></property>
      <property name="suffix" value=".jsp"></property>
  </bean>

   <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource"
    id="dataSource">
      <property name="driverClassName" value="${message.driver}"></property>
      <property name="url" value="${message.url}"></property>
      <property name="username" value="${message.user}"></property>
      <property name="password" value="${message.password}"></property>
  </bean>



   <bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="com.springLogin.entity" />
    <property name="hibernateProperties">
       <props>
          <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}  </prop>
          <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
          <prop key="hibernate.dialect">${hibernate.dialect}</prop>
       </props>
    </property>
  </bean>

   <bean class="org.springframework.orm.hibernate4.HibernateTransactionManager"
    id="hibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"></property>
   </bean> 
 </beans

${hibernate.hbm2ddl.auto}
${hibernate.show_sql}
${hibernate.dial}

如果我错了,请原谅。。。有什么帮助吗?

没有错误,只是调试信息。@M.Deinum…是的。但我想问一下为什么返回空视图…而不返回匹配模式…尽管它在控制器中…请帮助没有匹配模式(这就是消息告诉您的)。。。如上所述,它只是信息/调试/跟踪日志记录。关于模型,它是一个没有模型的重定向。
  <form method="POST" action="save" commandName="command">
    <table>
      <tr>
         <td>Employee ID:</td>
          <td><input type="text" name="id" readonly="true"/></td>
      </tr>
     <tr>
         <td>Employee Name:</td>
          <td><input type="text" name="name"/></td>
      </tr>
      <tr>
         <td>Employee Age:</td>
         <td><input type="text" name="age"/></td>
      </tr>
      <tr>
          <td>Employee Salary:</td>
          <td><input type="text" name="salary"/></td>
       </tr>

       <tr>
         <td>Employee Address:</td>
                  <td><input type="text" name="address"/></td>
      < /tr>
         <tr>
       <td colspan="2"><input type="submit" value="Submit"/></td>
      </tr>
 </table> 
 </form>