【问题标题】:How to handler form submits in team city plugin development jsp如何在teamcity插件开发jsp中处理表单提交
【发布时间】:2019-02-22 17:25:43
【问题描述】:

我正在学习如何使用 Java JSP 编写 TeamCity 插件。

我想有一个除文本信息外的表单并将其用于数据处理。

我面临的问题是单击提交按钮时出现 404。

控制器

public class ServerConfigGeneralController extends BaseFormXmlController {
      public ServerConfigGeneralController(@NotNull SBuildServer server,
                                           @NotNull WebControllerManager webControllerManager) {
        super(server);
        webControllerManager.registerController("/admin/", this);
      }

      @Override
      @Nullable
      protected ModelAndView doGet(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response) {
          System.out.println("######In Model and View########");
        return null;
      }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response, Element xmlResponse) {
        // TODO Auto-generated method stub

        System.out.println("######In Do Post########");

    }

}

jsp

<html>
    <h1>Consul Key Value settings</h1>
   <body>

      <form action = "ServerConfigGeneralController" method = "post">
         URL: <input type = "text" name = "url">
         <br />
         Port: <input type = "text" name = "port" />
         <input type = "submit" value = "Submit" />
      </form>

   </body>
</html>

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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
       default-autowire="constructor">

       <bean class="com.demoDomain.teamcity.demoPlugin.AppServer"></bean>
       <bean id="MyListener" class="com.demoDomain.teamcity.demoPlugin.MyListener"></bean>
       <bean id="TestAdminPage" class="com.demoDomain.teamcity.demoPlugin.TestAdminPage"></bean>
       <bean id ="ServerConfigGeneralController" class="com.demoDomain.teamcity.demoPlugin.ServerConfigGeneralController"></bean>
</beans>

我希望调用 do Post 并将 Sys out 打印在团队城市服务器控制台上。

感谢您的帮助。

【问题讨论】:

    标签: java jsp teamcity


    【解决方案1】:

    设法解决它。

    我需要获取表单动作来匹配控制器注册的 URL。

    <form action = "/admin/consul.html" method = "post">
    

    在控制器中

    manager.registerController("/admin/consul.html", this);
    

    谢谢

    【讨论】:

      猜你喜欢
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-06
      • 2013-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多