You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "carvin (JIRA)" <ji...@apache.org> on 2015/04/13 12:09:13 UTC
[jira] [Updated] (CXF-6348) POST data missing in HttpServletRequest
[ https://issues.apache.org/jira/browse/CXF-6348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
carvin updated CXF-6348:
------------------------
Affects Version/s: 3.0.4
> POST data missing in HttpServletRequest
> ---------------------------------------
>
> Key: CXF-6348
> URL: https://issues.apache.org/jira/browse/CXF-6348
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.0.4
> Environment: Tomcat maven plugin 2.2
> JDK 1.7.0_60
> Reporter: carvin
>
> Code:
> == Service ==
> {code}
> @Path("/login")
> public class LoginService {
> @POST
> @Produces(MediaType.TEXT_PLAIN)
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> public String login(@Context HttpServletRequest request) {
> String name = request.getParameter("name");
> System.out.println("name : " + name); // The name is null
> if("test".equals(name)) {
> return "SUCCESS";
> }
> return "FAIL";
> }
> }
> {code}
> == Spring config file ==
> {code: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:jaxrs="http://cxf.apache.org/jaxrs"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
> <import resource="classpath:META-INF/cxf/cxf.xml"/>
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> <jaxrs:server id="posCenterService" address="/">
> <jaxrs:serviceBeans>
> <bean class="com.carvin.cxf.jaxrs.services.LoginService" />
> </jaxrs:serviceBeans>
> <jaxrs:extensionMappings>
> <entry key="json" value="application/json"/>
> <entry key="xml" value="application/xml"/>
> </jaxrs:extensionMappings>
> <jaxrs:languageMappings>
> </jaxrs:languageMappings>
> </jaxrs:server>
> </beans>
> {code}
> === web.xml ===
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
> version="3.0"
> metadata-complete="false">
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>
> classpath*:spring/spring-*.xml
> </param-value>
> </context-param>
> <listener>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
> </listener>
> <servlet>
> <servlet-name>CXFServlet</servlet-name>
> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>CXFServlet</servlet-name>
> <url-pattern>/services/*</url-pattern>
> </servlet-mapping>
> </web-app>
> {code}
> === Test html file ===
> {code:xml}
> <!DOCTYPE html>
> <html>
> <head>
> <meta charset="utf-8">
> </head>
> <body>
> <form id="fm" method="POST" action="http://localhost:8080/cxf/services/login">
> name:<input type="text" name="name">
> </form>
> <button onclick="visit()">submit</button>
> <script>
> function visit() {
> document.getElementById("fm").submit();
> }
> </script>
> </body>
> </html>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)