cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "carvin (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-6348) POST data missing in HttpServletRequest
Date Mon, 13 Apr 2015 10:08:12 GMT
carvin created CXF-6348:
---------------------------

             Summary: 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
         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)

Mime
View raw message