com.opensymphony.xwork2.DefaultTextProvider Showed in Struts2 Text field value

180 views Asked by At

My JSP is getting the parameters from the URL and it is working fine. But if there is no parameters in the URL, the text field's value shows com.opensymphony.xwork2.DefaultTextProvider.

Like when the URL is login.jsp?user=USER1, it outputs USER1. But if it's login.jsp it shows com.opensymphony.xwork2.DefaultTextProvider

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<%@ taglib prefix="html" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

String user = request.getParameter("user");
        if(user == null) user = "";

<c:set var="user"><%=user%></html:set>
<c:textfield id="user" name="user" value='%{#user}'/>
1

There are 1 answers

0
Roman C On BEST ANSWER

You don't need to use scriptlets and JSTL tags to get a request parameter.

Instead you can access parameters via OGNL. Use naming prefix for taglibs.

<%@ taglib prefix="s" uri="/struts-tags"%>

<s:textfield id="user" name="user" value="%{#parameters.user}"/>